I am trying to tie budget totals to sales using fiscal year and fiscal period since the budget table does not have the date column that the sales table has. I am trying to aggregate the budget table to sum some budget numbers by fiscal year and period. Here is what I have.
SELECT
BRANCH_ID, BRANCH_NAME, FISCAL_YEAR, FISCAL_PERIOD, sum(GL_BUDGET) AS I_NEED_TO_FILTER_THIS
FROM
connection.subsection.FACT_BRANCH_BUDGET
WHERE
FISCAL_YEAR = '2022'
GROUP BY
BRANCH_ID, BRANCH_NAME, FISCAL_YEAR, FISCAL_PERIOD
Order by
BRANCH_ID, BRANCH_NAME, FISCAL_YEAR, FISCAL_PERIOD
This gives me the summations for each branch, fiscal year and fiscal period but I am having difficulty with the CASE statement. I need to filter for only certain codes under GL_ACCOUNT_NUMBER but keep getting errors.
Thanks.