var sidebar_align = 'right';
var content_container_margin = parseInt('290px');
var sidebar_width = parseInt('270px');
Unanswered: 10 top results query - HOW?
i have a table in this format
status | count
A | 10
the question is:
i need a query that does the following:
select from this table the 10 highest counts and there status
and they also should be in desc order
can any one help me?
Although that only gets you the first 10. If there are any records which share the same value for count, you probably want those to display, which means you might have more than 10 records appearing.
from (select status, count_field from table order by count_field desc)
where rownum < 11
This SQL gives you the n'th highest value (the 5th highest in this example)
So you could incorporate that to get all records with the 10 highest values
SELECT MIN(field1) FROM
(SELECT distinct field1
ORDER BY field1 DESC)
WHERE rownum <= n
WHERE count_field <= (SELECT MIN(count_field)
FROM (SELECT distinct count_field
ORDER BY count_field DESC)
WHERE rownum <= 5)
Last edited by chuck_forbes; 09-28-05 at 11:56.