how to retrieve 1st and last row of table without using
group functions??
Answers were Sorted based on User's Feedback
Answer / prabhudatta
SELECT * FROM (SELECT * FROM EMP ORDER BY EMP_NO) WHERE
ROWNUM=1
UNION
SELECT * FROM (SELECT * FROM EMP ORDER BY EMP_NO DESC)
WHERE ROWNUM=1;
Is This Answer Correct ? | 14 Yes | 4 No |
Answer / sudipta santra
For the 1st row:
select * from emp where rownum<2 order by empno;
For the last row:
select * from emp where rownum<2 order by empno desc;
Is This Answer Correct ? | 14 Yes | 5 No |
Answer / nathan
SELECT *
FROM (SELECT emp.*, ROWNUM rn
FROM emp)
WHERE rn = 1 OR rn = (SELECT COUNT (*)
FROM emp);
Is This Answer Correct ? | 3 Yes | 0 No |
Answer / rajesh
SELECT * FROM (SELECT * FROM EMP ORDER BY EMP_NO) WHERE
ROWNUM < 2
UNION
SELECT * FROM (SELECT * FROM EMP ORDER BY EMP_NO DESC)
WHERE ROWNUM < 2;
Is This Answer Correct ? | 2 Yes | 0 No |
Answer / ajay reddy
Select * from (select e.*,rownum r from emp e) where r in(1,(select count(*) from emp));
Is This Answer Correct ? | 0 Yes | 0 No |
What is Hash Index?
Please explan Why static query is more faster than dynamic query ?
How do I learn what codesets are available in oracle?
What is oracle server autotrace in oracle?
Can Multiple instances be run on Single Machine???
5. Display full details for the creditor/s who has received the single largest payment. Do not use a table join or set operator anywhere in your query.
What is the difference between hot backup and cold backup in oracle? Tell about their benefits also.
Are truncate and delete commands same? If so why?
What is translate in oracle?
In Oracle 9i what does "i" Stands for?
What is procedure overloading in oracle?
How can we manage the gap in a primary key column created by a sequence? Ex:a company has empno as primary key generated by a sequence and some employees leaves in between.What is the best way to manage this gap?