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
 SQL Server 2005 Forums
 Other SQL Server Topics (2005)
 View Based on A Fiscal Year

Author  Topic 

omega1983
Starting Member

40 Posts

Posted - 2009-05-26 : 15:59:47
Platform: MS SQL Server 2005

I am trying to construct an sql view based on a fiscal year starting with 7(July) and ending with 6(June). I will eventually use totals for a 4 year fiscal year. If the giftdate falls within the date range, I want to list the totals in the correct fiscal year. I want a total for pastdue,fy2008,2009,2010 and 2011

ie
Select sum(giftamount) as paymentsDue,giftkey
The output should look like this
pastdue $0.00 or amount
fy2008 $0.00 or amount
fy2009 $0.00 or amount
fy2010 $0.00 or amount
fy2011 $0.00 or amount

I am thinking I need a parameter based on a date range and several case statements

Any ideas?

SwePeso
Patron Saint of Lost Yaks

30421 Posts

Posted - 2009-05-26 : 18:14:53
Select sum(giftamount) as paymentsDue, datepart(year, dateadd(month, 6, giftdate)) AS fy
from table1
group by datepart(year, dateadd(month, 6, giftdate))



E 12°55'05.63"
N 56°04'39.26"
Go to Top of Page
   

- Advertisement -