Count of counts

From: Leif Neland <leif_at_roskildebc.dk>
Date: 1996/10/03
Message-ID: <32543F3A.5621_at_roskildebc.dk>#1/1


I need to make a count of counts. I want to know how many students are taking how many classes.
I start by doing:
SELECT student_id,count(class_id)
WHERE...
GROUP BY student_id;

I then get a list like
STUDENT_ID COUNT(CLASS_ID)
---------- ---------------

1254		3
1358		3
1359		2
2401		1

But how do I get to the result:

CLASSES      COUNT(...)
-------      ----------
     1		1
     2	        1
     3	        2

I can get by by creating a table from the first query, do a query on that
table, and finally dropping that table, but would like to avoid this method

Leif Neland
Systems administrator
Roskilde Business College
Denmark Received on Thu Oct 03 1996 - 00:00:00 CEST

Original text of this message