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)
 group by

Author  Topic 

sqlclarify
Yak Posting Veteran

56 Posts

Posted - 2008-10-09 : 00:47:09
I have several columns in my select

select a, b, c, q
from a
where etc. etc.

I want the sum of q grouped by a but I also want to display b,and c.

So logically
select a, b, c, sum(q)
from a
where etc. etc.
group by a, b, c

won't work even though that is syntatically correct. How do I solve this problem?

visakh16
Very Important crosS Applying yaK Herder

52326 Posts

Posted - 2008-10-09 : 00:57:58
select a, b, c, sum(q) over (partition by a)
from a
where etc. etc.
Go to Top of Page
   

- Advertisement -