BELOW example will give the middle row of the table(not sorted).
eg:
SELECT * FROM EMP WHERE ROWNUM <=(SELECT COUNT(1)/2 FROM EMP)
MINUS
SELECT * FROM EMP WHERE ROWNUM <(SELECT COUNT(1)/2 FROM EMP)
Login to rate this answer.
Below query will help you
SELECT * FROM EMP WHERE ROWNUM <=(SELECT COUNT(1)/2 FROM EMP)
MINUS
SELECT * FROM EMP WHERE ROWNUM <=(SELECT COUNT(1)/2 FROM EMP)

1 User has rated as useful.
Login to rate this answer.
Answered On : Aug 11th, 2011
The following query works as follows: If the table has ten records, it will display the 5th and 6th record and if it has some 11 records, will display 6th record alone.
Code
SELECT * FROM table_name WHERE ROWNUM <=
(SELECT CASE MOD(COUNT(1),2)
WHEN 0 THEN(COUNT(1)/2) + 1
ELSE ROUND(COUNT(1)/2) END FROM table_name)
MINUS
SELECT * FROM table_name
WHERE ROWNUM < (SELECT (COUNT(1)/2) FROM table_name)
Login to rate this answer.
SELECT * FROM EMP WHERE ROWNUM <=(SELECT COUNT(1)/2 FROM EMP)
MINUS
SELECT * FROM EMP WHERE ROWNUM >=(SELECT COUNT(1)/2 FROM EMP)
Login to rate this answer.
Nazeera Jaffar
Answered On : Sep 26th, 2012
The below code returns the rows from 50-74
Code
TO SELECT the middle rows:
SELECT * FROM TABLE offset 50 rows fetch next 25 rows only
Login to rate this answer.
Nazeera Jaffar
Answered On : Sep 26th, 2012
The below code selects the exact middle row from the table
Code
SELECT * FROM TABLE WHERE rownum=trunc(SELECT count(*)/2 FROM TABLE)
Login to rate this answer.