Groups | Blog | Home
all groups > sql server mseq > october 2007 >

sql server mseq : Aggregate rows in a Table



Sasikumar
10/17/2007 2:14:14 PM
Hi,

I have a Table with rows as below

A 1 10
B 1 15
A 2 3
A 1 5
A 3 10

Since the 1st & 4th row has values of A & 1 in first & second column, I wanted to aggregate the values in third colum. I wanted the result to be

B 1 15
A 2 3
A 1 15
A 3 10

How can this be done?

From http://www.developmentnow.com/g/108_2004_3_0_0_0/sql-server-mseq.htm

Posted via DevelopmentNow.com Groups
Hugo Kornelis
10/17/2007 11:44:34 PM
[quoted text, click to view]

SELECT Col1, Col2, SUM(Col3)
FROM SomeTable
GROUP BY Col1, Col2;

--
Hugo Kornelis, SQL Server MVP
AddThis Social Bookmark Button