Home » RDBMS Server » Server Administration » better way to do this
better way to do this [message #372499] Thu, 15 February 2001 18:33 Go to next message
Mike
Messages: 417
Registered: September 1998
Senior Member
If I want to grab 2 items of data for the largest values of one of the items - can i do this in one query statement?

for example:
SELECT EX_ID,COUNT FROM EX_VIEW_COUNT ORDER BY COUNT

where I only want 10 items(rows) where the COUNT values are the greatest values (like a reverse order sort on COUNT).

any ideas?

TIA!
--Mike
(http://www.js-examples.com)
Re: better way to do this [message #372502 is a reply to message #372499] Fri, 16 February 2001 02:55 Go to previous messageGo to next message
Tittom
Messages: 15
Registered: November 2000
Junior Member
Try something like this :

select * from
( SELECT EX_ID,COUNT FROM EX_VIEW_COUNT
ORDER BY COUNT DESC
)
where rownum <= 10

I did not test this but it is the idea

I hope this helps
Tittom
Re: better way to do this [message #372518 is a reply to message #372499] Sat, 17 February 2001 14:36 Go to previous message
Tittom
Messages: 15
Registered: November 2000
Junior Member
This is right.

I didn't know the "limit" key word existed in
Oracle

Thanks
Previous Topic: Re: Alright Smart Guys... Here's a simple one.
Next Topic: write a query!
Goto Forum:
  


Current Time: Sat May 18 03:59:16 CDT 2024