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 |
How to name query output columns in oracle?
can you call insert/update/delete in select statements. If yes how? If no what is the other way?
What is a deadlock in SQL? How can you prevent it?
How to create a temporary table in oracle?
What is trigger associated with the timer ?
How much memory your 10g xe server is using?
What are the differences between lov and list item?
write a query to dispaly those name who is more than one in student table? example- in a student table sandeep kumar comes 4 times, rakesh kumar comes 2 times, ajit kumar comes 1 times so query will display sandeep kumar and rakesh kumar single times.
How is it different from a normal table?
what is the need of indexing topic in oracle? where do we use in a Java project? any other option other than using this to get the same result where we use indexing ?
How to use subqueries with the exists operator in oracle?
what is grid in Oracle 10g...