Anyone have a good method if I could like to do the following:
Table:
Craete table DATA
(INPUTTIME DATE,
ARTICLECODE VARCHAR2(10)
);
All data is not sort by DATA.INPUTTIME inside table.
There are total more than 50000 record, but if I could like to get the first 20 record, but require to sort by DATA.INPUTTIME first.
ie. select first 20 record from (select articlecode from data order by inputtime; ) order by inputtime;
If I have this sql, but the result speed is very slow.
select * from (
select rownum as rn articlecode
from data
order by inputtime) temp where temp.rn between 1 and 20;
but this SQL will return 20 records after processed 5000 record, due to sub-query will process 5000 records.
Anyone have a good method??? Markco Wong
Table:
Craete table DATA
(INPUTTIME DATE,
ARTICLECODE VARCHAR2(10)
);
All data is not sort by DATA.INPUTTIME inside table.
There are total more than 50000 record, but if I could like to get the first 20 record, but require to sort by DATA.INPUTTIME first.
ie. select first 20 record from (select articlecode from data order by inputtime; ) order by inputtime;
If I have this sql, but the result speed is very slow.
select * from (
select rownum as rn articlecode
from data
order by inputtime) temp where temp.rn between 1 and 20;
but this SQL will return 20 records after processed 5000 record, due to sub-query will process 5000 records.
Anyone have a good method??? Markco Wong