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
 Transact-SQL (2000)
 pivot report

Author  Topic 

jung1975
Aged Yak Warrior

503 Posts

Posted - 2003-10-22 : 16:42:31
Following query return total loss amount by years.


SELECT year(clm_incdate) as year ,
sum(loss_amt) as lossamt
from loss inner join (claim inner join location_xref as x on claim.ref_location = x.location_key)
on loss.loss_claim = claim.claim_key
where x.ref_loc1 = 586238169
group by year(clm_incdate)
order by year(clm_incdate)
----------------------------------------------------
year lossamt
----------- ----------------------------------------
1994 202810.27
1995 528428.64
1996 569571.78
1997 357958.82
1998 187530.07
1999 420007.25
2000 666091.11
2001 235586.32
2002 371557.96
2003 43951.56


I would like to crete a report that shows the loss amount broken down by months. So, the output looks similar like this:


year Jan Feb Mar ..... Dec
---------------------------------------------
1994 ##### ##### #####..... #####
1995
1996
1997
1998
1999
2000
2001
2002
2003


Jung





jsmith8858
Dr. Cross Join

7423 Posts

Posted - 2003-10-22 : 16:47:02
If you search these forums for "pivot" you'll find about 100 different ways !

- Jeff
Go to Top of Page
   

- Advertisement -