Dynamic fiscal year query
I have several years (and growing) of data that I need to query whose results need to be grouped by our fiscal years,
Oct to Sep.
So I don't have to create a new sub-query and edit the primary query every year, I would like to have a dynamic moving window of time that goes back 5 fiscal years or so, 1 sub query per fiscal year counting back from the current one.
As an example a sub-query for the last fiscal year would be something like:
-
Sub-Query name: "FY-1"
SELECT
"Staff_ID",
"Amount"
FROM "Staff_Salary"
WHERE Salary_Start_Date" =
[?? CURRENT FISCAL YEAR -1 ??]
The primary query would be something like:
- SELECT
- t1."Staff_Name" "Name",
- t2."Amount" "Curent FY Amount",
- t3."Amount" "Previous FY Amount"
- FROM "Staff" t1
- LEFT JOIN "FY_Curr" t2 ON t2.Staff_ID = t1.Staff_ID
- LEFT JOIN "FY-1" t3 ON t3.Staff_ID = t1.Staff_ID
Again, I'm trying to do this so I never have to edit it every year.
Thanks,
For you help