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 |
|
arbaaz_Khan
Starting Member
3 Posts |
Posted - 2009-09-11 : 12:47:32
|
| Below is the table returned from the sql query. I need to add up all the values of the numbers column. I am having a hard time in doing that...Can anyone help me plzzSelect Count(distinct activity_id, type) as numbers,activity_id, type FroM table1Group by activity_idhaving numbers > 1 numbers activity_id type23 jkj soft1 jjkp hard |
|
|
webfred
Master Smack Fu Yak Hacker
8781 Posts |
Posted - 2009-09-11 : 14:14:55
|
select count(*) as numbers, activity_id, typefrom table1group by activity_id, typehaving count(*) > 1If that is not what you want be a bit more clear please. No, you're never too old to Yak'n'Roll if you're too young to die. |
 |
|
|
arbaaz_Khan
Starting Member
3 Posts |
Posted - 2009-09-11 : 16:17:35
|
| Okay...the query below works fine--------------Select Count(distinct activity_id, type) as numbers,activity_id, typeFroM table1Group by activity_idhaving numbers > 1-------------------It creates a column named as numbers. I need to get the sum on the values of the fields in that column.For example...from the above table it should add up fields 23 and 1 from columns numbers and output itnumbers activity_id type23 jkj soft1 jjkp hardI hope I made it clear this time. |
 |
|
|
webfred
Master Smack Fu Yak Hacker
8781 Posts |
Posted - 2009-09-11 : 16:30:39
|
select sum(numbers) from(Select Count(distinct activity_id, type) as numbers,activity_id, typeFroM table1Group by activity_idhaving numbers > 1)dt No, you're never too old to Yak'n'Roll if you're too young to die. |
 |
|
|
arbaaz_Khan
Starting Member
3 Posts |
Posted - 2009-09-11 : 16:38:07
|
Thanks a lot...that's what I was looking for |
 |
|
|
webfred
Master Smack Fu Yak Hacker
8781 Posts |
Posted - 2009-09-11 : 16:39:27
|
fine  No, you're never too old to Yak'n'Roll if you're too young to die. |
 |
|
|
|
|
|
|
|