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.
| Author |
Topic |
|
Scott
Posting Yak Master
145 Posts |
Posted - 2002-02-21 : 07:10:18
|
| I have a table with a date field and a money fieldI want the total money spent in each financial year (1 April to 31 March)Sum(Money field) ... group by financial year??? |
|
|
robvolk
Most Valuable Yak
15732 Posts |
Posted - 2002-02-21 : 07:21:15
|
| SELECT DateName(year, DateAdd(qq, -1, dateColumn)) FinancialYear,Sum(moneyColumn) TotalFROM myTableGROUP BY DateName(year, DateAdd(qq, -1, dateColumn))DateAdd will subtract 1 quarter from the date column in your table; this will move dates before April 1 into the previous year, then DateName will extract the year and GROUP on it. |
 |
|
|
|
|
|