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 2000 Forums
 SQL Server Development (2000)
 Multiple computations and grouping SQL

Author  Topic 

rum23
Yak Posting Veteran

77 Posts

Posted - 2009-05-27 : 06:00:12

Currently, I have table with following info

PaidDate Amount ID
-----------------------------------------
4/15/2008 100.00 1
4/20/2008 250.00 2
05/05/2008 50.00 3
5/17/2008 130.00 4
09/20/2008 175.00 5
10/29/2009 200.00 6
11/28/2009 500.00 7
12/15/2009 600.00 8
01/13/2010 200.00 9
01/25/2010 300.00 10
03/29/2010 400.00 11

Now I want to get the data in the following format.

FinancialYear QuarterNumber TotalAmount
------------------------------------------------------
FY07/08 Q3 530.00(ID's: 1+2+3+4)
FY07/08 Q4 175.00(ID's: 5)
FY09/10 Q1 1300.00(ID's: 6+7+8)
FY09/10 Q2 900.00 (ID's: 9+10+11)

Any given financial Year starts on October 1st and ends on Sept 30th of the following year. (e.g.: 10/1/2008 to 9/30/2009). Each financial year has 4 quarters (Q1, Q2,Q3,Q4).
Q1 - Oct, Nov, Dec
Q2 - Jan, Feb, Mar
Q3 - Apr, May, June
Q4 - July, Aug, Sep

The PaidDate determines the Financial year and the month in the paid date determines the quarter.

I want to sum the Amounts based on Financial year and then the quarters. Is this possible to do in SQL?

Thanks!

rum



SwePeso
Patron Saint of Lost Yaks

30421 Posts

Posted - 2009-05-27 : 06:52:23
Duplicate post.
Continue here http://www.sqlteam.com/forums/topic.asp?TOPIC_ID=126541



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

- Advertisement -