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
 Group BY

Author  Topic 

divan
Posting Yak Master

153 Posts

Posted - 2013-05-23 : 09:24:40
I have written the following script

SELECT SUM (F.AMOUNT) AS AMOUNT, C.PRINT_TIME AS YEAR
FROM CLAIM_FNCL_TRANS F
INNER JOIN CHECKS C ON F.INSTRUMENT_KEY = C.PHNX_GUID
WHERE F.ACCOUNT_CD = 'E' AND F.TRANS_TYPE_CD = 'E'
GROUP BY C.PRINT_TIME

which works perfectly and I get the following result

11385.32 2011-02-16 08:50:47.470
354.83 2013-05-21 18:00:46.803
1044.75 2013-05-21 18:01:58.090
3580.77 2013-05-21 18:01:20.113
6265.22 2009-03-11 09:12:31.150
5355.00 2013-05-21 18:01:29.670

what I really need to see is the amount just by year. example
6265.22 2009
11385.32 2011
10295.35 2013

MIK_2008
Master Smack Fu Yak Hacker

1054 Posts

Posted - 2013-05-23 : 09:26:32
Replace C.PRINT_TIME with Year(C.PRINT_TIME) in select and group by clause

Cheers
MIK
Go to Top of Page

shettybhas
Starting Member

3 Posts

Posted - 2013-05-23 : 09:51:16
In column list also replace it YEAR(c.Print_Time)
Go to Top of Page

divan
Posting Yak Master

153 Posts

Posted - 2013-05-23 : 14:46:41
Thanks this worked...
Go to Top of Page
   

- Advertisement -