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)
 Help with Select, Case

Author  Topic 

daisy
Starting Member

13 Posts

Posted - 2005-04-11 : 10:08:13
From one table I need to combine totals from a few different
id's:

select member_id =
case when member_id = 257
then 222
when member_id = 255
then 247
when member_id = 256
then 247
else member_id
end,
sum(final)
From PP_Counts
where job_id = 923
group by member_id, final


looks like this:
member_id final

1. 190 7304
2. 222 9914
3. 230 4958
4. 245 13252
5. 247 12580
6. 249 8083
7. 252 6976
8. 247 968
9. 247 333
10.222 2484

my question is how to call id's with final total's
to look like this?
member_id final

1. 190 7304
2. 222 12398
3. 230 4958
4. 245 13252
5. 247 13881
6. 249 8083
7. 252 6976

Everything I've tried doesn't work?



mr_mist
Grunnio

1870 Posts

Posted - 2005-04-11 : 10:27:55
select member_id =
case when member_id = 257
then 222
when member_id = 255
then 247
when member_id = 256
then 247
else member_id
end,
sum(final)
From PP_Counts
where job_id = 923
group by member_id



-------
Moo. :)
Go to Top of Page

daisy
Starting Member

13 Posts

Posted - 2005-04-11 : 10:45:47
Thanks for replying so fast but that isn't working.

When I run that, it just lists all the member_id's with
final totals it doesn't combine totals together were the
same id is listed.
Go to Top of Page

mr_mist
Grunnio

1870 Posts

Posted - 2005-04-11 : 10:56:15
select member_id =
case when member_id = 257
then 222
when member_id = 255
then 247
when member_id = 256
then 247
else member_id
end,
sum(final)
From PP_Counts
where job_id = 923
group by case when member_id = 257
then 222
when member_id = 255
then 247
when member_id = 256
then 247
else member_id
end



-------
Moo. :)
Go to Top of Page

daisy
Starting Member

13 Posts

Posted - 2005-04-11 : 11:08:19
Thanks Moo you stud!
Go to Top of Page
   

- Advertisement -