Three Questions:

1. Select the first and last rows from a table.

2.Select even rows from a table.

3.Select odd rows from a table.

All have to be done using the ROWNUM pseudo-coloumn.

Now ROWNUM is assigned to a record everytime it is inserted as below

SQL> select rownum, emp_id,ename from emp;

ROWNUM EMP_ID ENAME
---------- ---------- --------------------
1 1 sid
2 2 aalap
3 3 priti
4 4 rothi
5 5 niya

SQL> select rownum, emp_id, ename from emp order by ename desc;

ROWNUM EMP_ID ENAME
---------- ---------- --------------------
1 1 sid
4 4 rothi
3 3 priti
5 5 niya
2 2 aalap

So as is evident the point that a row can only be first or last if ordered by a key, which rules out ROWNUM is invalidated, since we're talking for the range of this problem in "PRIORITY OF INSERTION" sense.

Sooooo


SQL> select * from emp where rownum = 1;

EMP_ID ENAME SAL
---------- -------------------- ----------
1 sid 80000

SQL> select * from (select * from emp order by rownum desc) where rownum = 1;

EMP_ID ENAME SAL
---------- -------------------- ----------
5 niya 330


That does it for the first and last row.

For the even and odd, Im failing with ROWNUM as any
... where ROWNUM = ... other than ROWNUM = 1 doesn't work and only where ROWNUM < works.

So this is useless

select * from emp where mod(rownum,2) = 0;

select * from emp where mod(rownum,2) = 1;

Any hints.

Please.

"How fast can this thing go?"