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 |
pelegk2
Aged Yak Warrior
723 Posts |
Posted - 2007-11-21 : 11:59:06
|
i have a table that i need to update like this :TableA structure : name,good (int),bad(int),date(bigint of type yyyymmddhhmmss)i am making an insert on this tablel like this :insert into tableA select name,count(*),0,datefrom xxxxwhere event in (1,2,3)the thing is that the column of bad i can feel when the event is (5,6,7)can i join both of the insert into 1 to get 1 complete table and not like currently with duplicate rows?thnaks i nadvancepelegIsrael -the best place to live in aftr heaven 9but no one wan't to go there so fast -:) |
|
khtan
In (Som, Ni, Yak)
17689 Posts |
Posted - 2007-11-21 : 12:07:00
|
[code]insert into tableA (name, good, bad, date)select name, sum(case when event in (1,2,3) then 1 else 0 end), sum(case when event in (5,6,7) then 1 else 0 end), datefrom xxxxgroup by name, date[/code] KH[spoiler]Time is always against us[/spoiler] |
 |
|
pelegk2
Aged Yak Warrior
723 Posts |
Posted - 2007-11-21 : 12:11:29
|
cool thnaks alot!Israel -the best place to live in aftr heaven 9but no one wan't to go there so fast -:) |
 |
|
|
|
|
|
|