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
 SQL Server Development (2000)
 Reporting Question: Counting Values without subqueries

Author  Topic 

AskSQLTeam
Ask SQLTeam Question

0 Posts

Posted - 2002-03-01 : 08:54:11
Dan writes "Using SQL 2000 sp1, win 2k sp2

I am currently storing information on downloads - with two related tables, one for the download info, and the other for the area in which the download occured(classID).

Anyways, I have a result set that looks like this:


DownloadID classid partid
-------------------- ----------- -----------
1 34 70529
2 34 70529
3 34 71120
4 44 71188
5 44 70911
6 34 71191


How would I return a result that that counted classid's, looked something like:


classid numdl
----------- --------
34 4
44 2


Thanks much."

robvolk
Most Valuable Yak

15732 Posts

Posted - 2002-03-01 : 09:04:00
SELECT classid, Count(*) numdl FROM myTable GROUP BY classid ORDER BY classid

Go to Top of Page
   

- Advertisement -