Oracle FAQ Your Portal to the Oracle Knowledge Grid
HOME | ASK QUESTION | ADD INFO | SEARCH | E-MAIL US
 

Home -> Community -> Usenet -> c.d.o.server -> Tricky SQL question

Tricky SQL question

From: Canberra <ctcanb_at_mail.zip.com.au>
Date: 3 Jan 1999 22:41:25 GMT
Message-ID: <01be376a$c0707890$35140c0a@eagle>


Hi all.

I hope someone can help with the following Oracle SQL problem.

Consider the following table:

SQL> desc keyword;

 Name                            Null?    Type
 ------------------------------- -------- ----
 ID_OBJECT                       NOT NULL VARCHAR2(16)
 KEYWORD                         NOT NULL VARCHAR2(100)

For each value of id_object there can one or more keyword.

I need to work out a query that will return only the 10 most frequently occuring keywords.
So far I have:

	select distinct (keyword), count(keyword)
	from keyword k
	group by keyword
	order by 2 desc;

This shows the number of occurences of each keyword.

How can I only show the 10 most frequently occuring keywords ? Is a PL/SQL procedure (or function) the answer ?

Any help gratefully accepted.

Thanks in advance,

-Richard Barrott
ctcanb_at_mail.dynamite.com.au
u952297_at_student.canberra.edu.au Received on Sun Jan 03 1999 - 16:41:25 CST

Original text of this message

HOME | ASK QUESTION | ADD INFO | SEARCH | E-MAIL US