Hi I'm trying to calculate the RT(Running total) based on the Key and Period fields
Using the following SQL but doesn't generate the right result, please can you assist me with that
The 3rd column RT is the output on excel but idea so to generate similar result using SQL
Thanks
Using the following SQL but doesn't generate the right result, please can you assist me with that
The 3rd column RT is the output on excel but idea so to generate similar result using SQL
SQL:
SELECT
Budget_2025.[Fiscal Year]&Budget_2025.[Cost Centre Code]&Budget_2025.[Subjective Code]&Budget_2025.[Analysis One Code]&Budget_2025.[Analysis Two Code] As Key,
Budget_2025.[Fiscal Period Number],
Budget_2025.IM_WTEPlan AS IM_WTEPlan,
(
SELECT SUM(x2.IM_WTEPlan)
FROM Budget_2025 as x2
WHERE x2.[Fiscal Year]&x2.[Cost Centre Code]&x2.[Subjective Code]&x2.[Analysis One Code]&x2.[Analysis Two Code]
= Budget_2025.[Fiscal Year]&Budget_2025.[Cost Centre Code]&Budget_2025.[Subjective Code]&Budget_2025.[Analysis One Code]&Budget_2025.[Analysis Two Code]
AND x2.[IM_WTEPlan] <= Budget_2025.IM_WTEPlan
) AS rt
FROM Budget_2025
WHERE (((Budget_2025.Currency)="STAT"))
AND Budget_2025.[Cost Centre Code] = "495150"
ORDER BY Budget_2025.[Cost Centre Code], Budget_2025.[Subjective Code], Budget_2025.[Fiscal Period Number];
[ATTACH type="full"]113279[/ATTACH]