SQL Server Forums
Profile | Register | Active Topics | Members | Search | Forum FAQ
 
Register Now and get your question answered!
Username:
Password:
Save Password
Forgot your Password?

 All Forums
 SQL Server 2008 Forums
 Transact-SQL (2008)
 help with query
 New Topic  Reply to Topic
 Printer Friendly
Author Previous Topic Topic Next Topic  

PGG_CA
Starting Member

16 Posts

Posted - 05/16/2012 :  15:54:52  Show Profile  Reply with Quote
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

USA
361 Posts

Posted - 05/16/2012 :  16:45:22  Show Profile  Reply with Quote
select assignee, totalmins = sum(minutes)
from thetable
group by assignee
Go to Top of Page
  Previous Topic Topic Next Topic  
 New Topic  Reply to Topic
 Printer Friendly
Jump To:
SQL Server Forums © 2000-2009 SQLTeam Publishing, LLC Go To Top Of Page
This page was generated in 0.03 seconds. Powered By: Snitz Forums 2000