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 2005 Forums
 Transact-SQL (2005)
 using sum function in a select

Author  Topic 

BitShift
Yak Posting Veteran

98 Posts

Posted - 2007-01-19 : 14:14:59
Lets say I have a table like so:

id
sales_person_id
sale_id
sale_type
sale_amount
description


There can be multiple records that share the same sale_id

How can I return a result with each row a summary of the total sale amount for a given sale_id and sales_person_id ?

SwePeso
Patron Saint of Lost Yaks

30421 Posts

Posted - 2007-01-19 : 14:24:06
select sales_person_id, sale_id, sum(sale_amount)
from blablabla
group by sales_person_id, sale_id

???


Peter Larsson
Helsingborg, Sweden
Go to Top of Page
   

- Advertisement -