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-08-06 : 03:53:15
|
i have a tablel ike this :id codes1 codes154 codes1810 codes111 codes19and i want to sum the total for each id.the thing is that i need for to convert the codes to numberfor example codes15=3,codes19=6.i dont have them in a table so i want to translate them as partof the query using a case statment.and in the end i want the total for each idhow cna i do it?thnaks in advancepelegIsrael -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-08-06 : 04:00:05
|
[code]SELECT id, SUM(CASE codes WHEN 'codes15' THEN 3 WHEN 'codes19' THEN 6 . . . END)FROM tablelGROUP BY id[/code] KH[spoiler]Time is always against us[/spoiler] |
 |
|
|
|
|