Display Odd/ Even number of records?

Answers were Sorted based on User's Feedback



Display Odd/ Even number of records?..

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

Display Odd/ Even number of records?..

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

Display Odd/ Even number of records?..

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

Post New Answer

More Oracle General Interview Questions

How to empty your oracle recycle bin?

0 Answers  


SELECT THE RECORDS FROM 3 TABLES LIKE(T1,T2,T3) AND HOW CAN WE INSERT THAT RECORD IN ANOTHER TABLE LIKE(T4)?

1 Answers   ESS,


When do I need to use a semicolon vs a slash in oracle sql?

0 Answers  


What is the cache hit ratio, what impact does it have on performance of an Oracle database and what is involved in tuning it?

0 Answers  


what is load balancing and what u have used to do this?(sql loader)

3 Answers  






how can db_files > maxdatafiles since db_files is for instance and the later is for database

0 Answers   CTS,


Please explain me all types of Data models. Also give me the details if each model can have other name.for example:schematic data model is also known as conceptual data model and entity relation data model.

0 Answers  


Can we use bind variables in oracle stored procedure?

0 Answers  


What is the recommended interval at which to run statspack snapshots, and why?

0 Answers  


what is the difference between sql& oracle?

11 Answers   Oracle,


How i can handle exception in large code like 1000 line without distrubing the code or without exception handler sction?

0 Answers   Zensar,


How to find the date and time of last updated table?

4 Answers  


Categories
  • Oracle General Interview Questions Oracle General (1789)
  • Oracle DBA (Database Administration) Interview Questions Oracle DBA (Database Administration) (261)
  • Oracle Call Interface (OCI) Interview Questions Oracle Call Interface (OCI) (10)
  • Oracle Architecture Interview Questions Oracle Architecture (90)
  • Oracle Security Interview Questions Oracle Security (38)
  • Oracle Forms Reports Interview Questions Oracle Forms Reports (510)
  • Oracle Data Integrator (ODI) Interview Questions Oracle Data Integrator (ODI) (120)
  • Oracle ETL Interview Questions Oracle ETL (15)
  • Oracle RAC Interview Questions Oracle RAC (93)
  • Oracle D2K Interview Questions Oracle D2K (72)
  • Oracle AllOther Interview Questions Oracle AllOther (241)