Display Odd/ Even number of records?
Answers were Sorted based on User's Feedback
Answer / nishi
Select rownum,empno,ename,salary from emp group by rownum,empno,ename,salary having Mod(rownum,2)=0 -- To display EVEN records.
Select rownum,empno,ename,salary from emp group by rownum,empno,ename,salary having Mod(rownum,2)=1 -- To display ODD records.
Is This Answer Correct ? | 4 Yes | 0 No |
Answer / swastik mohanty
--TO FIND EVEN NUMBER
SELECT * FROM Table
WHERE ROWID IN (SELECT DECODE(MOD(ROWNUM, 2), 0, ROWID, NULL) FROM Table);
--TO FIND ODD NUMBER
SELECT * FROM Table
WHERE ROWID IN (SELECT DECODE(MOD(ROWID, 2), 1, ROWID, NULL) FROM Table);
Is This Answer Correct ? | 2 Yes | 0 No |
Answer / shareef
select * from emp where (rowid,0) in(select rowid,mod(rownum,2) from emp);---even
select * from emp where (rowid,1) in(select rowid,mod(rownum,2) from emp);---odd
Is This Answer Correct ? | 2 Yes | 0 No |
What is a dynamic performance view in oracle?
How to write a left outer join with the where clause in oracle?
what is the difference between restoring and recovering?
Can u make a synonym for deptno=10 only from emp table.
What is backup in Oracle?
Explain can a view based on another view?
What is execute immediate in oracle?
How would you begin to troubleshoot an ORA-3113 error?
What is a schema in oracle?
Why we use bulk collect in oracle?
What is an oracle and why it is used?
How can one skip any number of rows while loading the DB tables with SQL Loader? Similarly how can one skip any column?