Oracle FAQ | Your Portal to the Oracle Knowledge Grid |
Home -> Community -> Usenet -> c.d.o.server -> Tricky SQL question
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