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 2000 Forums
 Transact-SQL (2000)
 Select query for Counting some numbers

Author  Topic 

hasanali00
Posting Yak Master

207 Posts

Posted - 2005-03-11 : 10:28:42
Hi
I have thought long and ard about this select query, bit i just cannot think how to do it:

I have follwoing data:

Year Ponits
11 3
12 1
11 1
12 2

I want to run a query that will produce follwoing:

Year points
11 4
12 3

Basically, for every Year, i want to count the points.
Any ideas?? thanks

mr_mist
Grunnio

1870 Posts

Posted - 2005-03-11 : 10:32:55
SELECT year, sum(points) as [points] from yourtable group by year

-------
Moo. :)
Go to Top of Page

hasanali00
Posting Yak Master

207 Posts

Posted - 2005-03-11 : 10:54:16
can't thank u enough
Go to Top of Page

Hippi
Yak Posting Veteran

63 Posts

Posted - 2005-03-11 : 16:23:27
You should read BOL first, man. It's a very basic T-SQL.
Go to Top of Page
   

- Advertisement -