Please start any new threads on our new site at https://forums.sqlteam.com. We've got lots of great SQL Server experts to answer whatever question you can come up with.

 All Forums
 General SQL Server Forums
 New to SQL Server Programming
 Fiscal Year YTD and previous YTD

Author  Topic 

ziggy2015
Starting Member

11 Posts

Posted - 2016-04-03 : 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.

Thanks
Ziggy

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],
[Month]
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,
Previous_Financial_Year_YTD_Total,
cast(0 as float) as Previous_FinancialYearRunningtotal,

FROM dbo.table_base

Group by FinanacialYear, [Year],
[Month]
Admission_date,
Practice_Code,
locality
   

- Advertisement -