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 happens if the imported table already exists?
We have one Package(which has many function/procedures, SQL quires etc). Now we need to check, which query or procedure is taking lot of time in that Package. ? How do we do it.
How to loop through a cursor variable?
What is a Schema ?
How to use like conditions in oracle?
What is the difference between SQL and SQL Server?
How to find the date and time of last updated table?
waht is referencial integrity?
What is the Tune Query
What is varray?
What is pragma restrict_reference in oracle 9i?When we use this?Give me one realtime scenario?
Explain the use of control file?