DEVFYI - Developer Resource - FYI

Display Odd/ Even number of records?

ORACLE Interview Questions and Answers (Part 3)


(Continued from previous question...)

534. Display Odd/ Even number of records?

Odd number of records:
select * from emp where (rowid,1) in (select rowid, mod(rownum,2) from emp);
Output:-
1
3
5
Even number of records:
select * from emp where (rowid,0) in (select rowid, mod(rownum,2) from emp)
Output:-
2
4
6

(Continued on next question...)

Other Interview Questions