Re: Top ten again?

From: Dennis Hart <dennis_at_csadfa.cs.adfa.oz.au>
Date: Wed, 21 Apr 1993 23:22:30 GMT
Message-ID: <1993Apr21.232230.10127_at_sserve.cc.adfa.oz.au>


In article <sd345.735292697_at_Hampton>, sd345_at_city.ac.uk (Michael Collier) writes:
> Thanks to all the people who responded to my earlier post by
> by telling me to do a when rownum <= 10.
> However this doesn't seem to work, I'll show the query I actually run below.
>
> select subject, count(*)
> from adv_stats2
> group by subject
> order by count(*) desc;
>
> This gives me the following...
>
> SUBJECT COUNT(*)
> --------------- ----------
> WORDPERFECT 282
> UNIX 253
> DOS 86
> TRIVIAL 79
> PRINTING (UNIX) 71
> ELM 52
> PRINTING (DOS) 48
> HECATE 47
> WORDSTAR 46
> QBASIC 38
> C 32
> DESKSCAN 30
> AUTOCAD 29
> HARVARD 29
> QUATTRO PRO 27
> ORACLE 22
> WINDOWS 22
> BMDP 20
>
Michael,

Here's a way to do what you want:

	CREATE TABLE temp AS
	SELECT subject, count(*)
	FROM adv_stats2
	GROUP BY subject
	ORDER BY count(*) DESC;

	SELECT * FROM temp WHERE rownum <= 10;

	DROP TABLE temp;

Cheers, Dennis Hart Received on Thu Apr 22 1993 - 01:22:30 CEST

Original text of this message