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)
 Reporint Query: How do I do counts of a type?

Author  Topic 

danielhai
Yak Posting Veteran

50 Posts

Posted - 2002-02-26 : 14:55:55
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:

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

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

<pre>
classid numdl
----------- --------
34 4
44 2
</pre>

Thanks much.

Tigger
Yak Posting Veteran

85 Posts

Posted - 2002-02-26 : 15:19:02
SELECT CLASSID, COUNT(*) AS NUMDL
FROM TEMP
GROUP BY CLASSID

Replace TEMP with the name of your result set.

Go to Top of Page
   

- Advertisement -