Re: Aggregate rows in a Table
- From: Hugo Kornelis <hugo@xxxxxxxxxxxxxxxxxxxxxxxxxxxxxxx>
- Date: Wed, 17 Oct 2007 23:44:34 +0200
On Wed, 17 Oct 2007 21:14:13 GMT, Sasikumar wrote:
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?
SELECT Col1, Col2, SUM(Col3)
FROM SomeTable
GROUP BY Col1, Col2;
--
Hugo Kornelis, SQL Server MVP
My SQL Server blog: http://sqlblog.com/blogs/hugo_kornelis
.
- References:
- Aggregate rows in a Table
- From: Sasikumar
- Aggregate rows in a Table
- Prev by Date: Aggregate rows in a Table
- Next by Date: Re: indexes and selects
- Previous by thread: Aggregate rows in a Table
- Next by thread: Re: indexes and selects
- Index(es):
Relevant Pages
|
|