Posted - 04/03/2016 : 07:14:25
| Hi All,
Morning. I need help resolving this SQL problem. All I want is able to get YTD total , running total of the current financial year compare to the previous financial year. the fiscal period begins in April to march of every year. I have tried but not able to get what I want. I would be happy if someone can assist.
Declare @PrevfinYear varchar(25)
set @PrevfinYear = '2014/15'
Declare @CurrentfinYear varchar(25)
set @CurrentfinYear = '2015/16'
----Fiscal year start on the 01/04/2014 to 31/03/2015 respectively
SELECT FinanacialYear, [Year],
Admission_date, Practice_Code, locality,
SUM(value) AS Current_FinancialYear_Total,
sum(YTD_Total) as TD_Total,
cast(0 as float) as Current_FinancialYear_Running_Total,
cast(0 as int) as previous_FinanacialYearTotal,
cast(0 as float) as Previous_FinancialYearRunningtotal,
Group by FinanacialYear, [Year],