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
 General SQL Server Forums
 New to SQL Server Programming
 Group by

Author  Topic 

mukhan85
Starting Member

46 Posts

Posted - 2008-08-27 : 11:52:40
Hi how can I group by similar rows from the following table:
name value1 value2
----- ----------- -----------
Cancelled 85 33
Completed 716 108
No Stat/Closed 33 3
Open 36 17
Rejected 5 0
Successful/Closed 314 131
Backed Out/Closed 8 0
Cancelled 63 0
Successful/Closed 311 0
Unsuccessful/Closed 1 0


as you can see there are 2 rows with "Successful/Closed" and 2 rows with "Cancelled"

Thank you.

khtan
In (Som, Ni, Yak)

17689 Posts

Posted - 2008-08-27 : 11:55:12
[code]select name, sum(value1), sum(value2)
from yourtable
group by name[/code]


KH
[spoiler]Time is always against us[/spoiler]

Go to Top of Page

SwePeso
Patron Saint of Lost Yaks

30421 Posts

Posted - 2008-08-27 : 11:55:40
SELECT Name, SUM(Value1), SUM(Value2)
FROM Table1
GROUP BY Name



E 12°55'05.25"
N 56°04'39.16"
Go to Top of Page

SwePeso
Patron Saint of Lost Yaks

30421 Posts

Posted - 2008-08-27 : 11:55:55



E 12°55'05.25"
N 56°04'39.16"
Go to Top of Page
   

- Advertisement -