Home » RDBMS Server » Server Administration » query
query [message #371661] Tue, 21 November 2000 01:12 Go to next message
sanat Patel
Messages: 1
Registered: November 2000
Junior Member
Dear Members,
can you send me answer to the query that how to retrieve the first top 5 rows in the table in descending order wherein the rows are not ordered or inserted in an orderly fashion.

Sanat
Re: query [message #371663 is a reply to message #371661] Tue, 21 November 2000 02:58 Go to previous messageGo to next message
John R
Messages: 156
Registered: March 2000
Senior Member
Have a look at the 'Top x records' post furter down the list.
Re: query [message #371667 is a reply to message #371661] Wed, 22 November 2000 02:19 Go to previous message
J.S HAN
Messages: 12
Registered: November 2000
Junior Member
if you use under oracle version 8.1.5 then use this.
select order2, order1
from (
select order2, order1 from tab1
group by order1, order2
)
where rownum <= 5;

if you use index and want to sortong by indexed.
indexed column : order1 + order2
select /*+ index_desc(tab1 tab1_index) */
order2, order1
from tab1
where rownum <= 5;

if you use oracle version 8.1.6 then
select order2, order1
from (
select order2, order1, rank() over (order by order1, order2) as rnum from tab1
)
where rnum <= 5;

if you want more information, send me mail
Previous Topic: OCP Exam Papers
Next Topic: date update
Goto Forum:
  


Current Time: Sat May 04 07:07:01 CDT 2024