Level Extreme platform
Subscription
Corporate profile
Products & Services
Support
Legal
Français
Grouping
Message
From
25/04/2002 08:28:11
 
 
To
25/04/2002 04:33:14
General information
Forum:
Microsoft SQL Server
Category:
Other
Title:
Miscellaneous
Thread ID:
00649021
Message ID:
00649081
Views:
12
You could get this done with a derived table:
SELECT
 CurFinYear,
 SUM(ttl_amt)
FROM (
 SELECT 
  case month(sanct_dt)<=3 then year(sanct_dt)-1 else year(sanct_dt) as CurFinYear,
  ttl_amt
 FROM
  sanctionTable) AS x
GROUP BY
 CurFinYear
-Mike


>hi,
>I'm having a query like
>
>select case month(sanct_dt)<=3 then year(sanct_dt)-1 else year(sanct_dt) as CurFinYear, sum(ttl_amt) from sanctionTable
>
>the basic idea is to get the financial year for the sanction date based on the month and total the amount grouped on CurFinYear.
>
>I can't give CurFinYear in group by as it gives invalid col name error
>
>how to group the above sql ??? any other way is possible ?
>
>TIA
Michael Levy
MCSD, MCDBA
ma_levy@hotmail.com
Previous
Next
Reply
Map
View

Click here to load this message in the networking platform