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 2008 Forums
 Transact-SQL (2008)
 help with query

Author  Topic 

PGG_CA
Starting Member

24 Posts

Posted - 2012-05-16 : 15:54:52
I have the following output from my query.

Minutes Assignee
5 Aa
180 Bb
35 Cc
5 Aa
20 Dd
25 Bb

How can I rewrite the query so that instead of returning 2 rows each for Aa and Bb, it will only return one each and a total of the minutes. The output should look like this instead:

Minutes Assignee
10 Aa
205 Bb
35 Cc
20 Dd

Thanks.

influent
Constraint Violating Yak Guru

367 Posts

Posted - 2012-05-16 : 16:45:22
select assignee, totalmins = sum(minutes)
from thetable
group by assignee
Go to Top of Page
   

- Advertisement -