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 |
|
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.271995 528428.641996 569571.781997 357958.821998 187530.071999 420007.252000 666091.112001 235586.322002 371557.962003 43951.56I 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 |
 |
|
|
|
|
|