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 |
|
billyjeong
Starting Member
1 Post |
Posted - 2003-04-10 : 11:57:13
|
| I have some raw date. I'll make some query that it has CASE caluse.It's very difficult. can u have some soultions.Raw DateDate Code Amount---------------------------------------------03/01/2003 20001 570.0003/01/2003 20002 980.0003/01/2003 30001 180.0003/02/2003 30001 800.0003/02/2003 20002 800.00 Output ResultDate 20001 20002 30001------------------------------------------03/01/2003 570.00 980.00 180.0003/02/2003 800.00 800.00 |
|
|
claire
Starting Member
19 Posts |
Posted - 2003-04-10 : 12:14:12
|
| create table table1(Date varchar(10),Code int ,Amount money)goinsert into table1 select '03/01/2003',20001,570insert into table1 select '03/01/2003',20002,980insert into table1 select '03/01/2003',30001,180insert into table1 select '03/02/2003',30001,800insert into table1 select '03/02/2003',20002,800goselect date,sum(case code when 20001 then amount else 0 end)as '20001',sum(case code when 20002 then amount else 0 end)as '20002',sum(case code when 30001 then amount else 0 end)as '30001'from table1 group by datego |
 |
|
|
|
|
|
|
|