RE: HOw to get /select the nth row from the table ?
1- nth row from table
select * from emp where rownum< '&give_nth rows'
2- last nth rows
select * from emp where rownum< (select count(empno) from emp ) minus select * from emp where rownum< (select count(empno)-'&give_numberof _rows' from emp )
RE: HOw to get /select the nth row from the table ?
select * from aj a where rownum < (select count(rownum) from aj b where a.SCRIP_CD b.scrip_cd if you want to reterive ist row from the tableselect * from aj a where rownum (select count(rownum) from aj b where a.SCRIP_CD > b.scrip_cd)if you want to reterive last row from the table
RE: HOw to get /select the nth row from the table ?how to select first n rows ,last n rows from a table
to get the first n number of rows we can use
select * from emp where rowid in (select rowid from emp where rownum < &n minus select rowid from emp where rownum < 1);
in the same way to get the last n number of rows i.e last five or last two we can use
select * from emp where rowid in (select rowid from emp where rownum < (select count(empno) from emp) minus select rowid from emp where rownum < (select count(empno) - &n from emp));
also to get the last row inserted in the table we can use
select * from emp where rowid in (select max(rowid) from emp);
to get the first row inserted we can use select * from emp where rowid in (select max(rowid) from emp);