Display Odd/ Even 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
ii) for even number of records
select*from emp where rowid in(select decode(mod(rownum,2),0,rowid) from emp);
for odd number of records
select*from emp where rowid in(select decode(mod(rownum,2),1,rowid) from emp);
No comments:
Post a Comment