Write a query to get last 10 records from the table.

Answers were Sorted based on User's Feedback



Write a query to get last 10 records from the table...

Answer / jprakash025

select * from emp
minus
select * from emp
where
rownum<=(select count(*)-10 from emp);

or



SQL> select * from
2 (select rownum a, emp.* from emp)
3 where
4 a>(select max(rownum)-10 from emp);

Is This Answer Correct ?    24 Yes 2 No

Write a query to get last 10 records from the table...

Answer / l meher

select * from emp minus select * from emp where rownum<=
(select count(*)-10 from emp);

Is This Answer Correct ?    8 Yes 3 No

Write a query to get last 10 records from the table...

Answer / praveen biradar

select empno from (select empno from emp order by empno
desc) where rownum<=10 order by empno

Is This Answer Correct ?    10 Yes 6 No

Write a query to get last 10 records from the table...

Answer / pallavi v

with temp as
(select * from emp order by rownum desc)
select * from temp where rownum < = 10

Is This Answer Correct ?    0 Yes 0 No

Write a query to get last 10 records from the table...

Answer / siddharthapenchala

select * from <TN>
minus
select * from <TN>
where
rownum <= (select count(*) - &n from <TN>)

Is This Answer Correct ?    0 Yes 0 No

Write a query to get last 10 records from the table...

Answer / nzabin

select PO_header_id from (select PO_header_id from PO_HEADERS_ALL order by PO_header_id
desc) where rownum <=10 order by PO_header_id;

Is This Answer Correct ?    0 Yes 0 No

Write a query to get last 10 records from the table...

Answer / sudhir

select rownum, p.*
from (select * from <table name> order by param_cd desc) p
where rownum <= 10 ;

Is This Answer Correct ?    1 Yes 2 No

Write a query to get last 10 records from the table...

Answer / akshaya

select * from last10
minus
select * from last10
where row >= (select COUNT(*)-10 from last10)


condition should be >= not <=
for all the above queries

Is This Answer Correct ?    0 Yes 1 No

Write a query to get last 10 records from the table...

Answer / swastik

SELECT ROWNUM, E1.*
FROM
(
SELECT * FROM Emp
ORDER BY ROWNUM DESC
)E1
WHERE ROWNUM <= 10

Is This Answer Correct ?    0 Yes 1 No

Write a query to get last 10 records from the table...

Answer / chandrakishan

select * from emp where rownum>=
(select count(*)-10 from emp);

Is This Answer Correct ?    1 Yes 3 No

Post New Answer

More SQL PLSQL Interview Questions

What is query syntax?

0 Answers  


What is indexes?

0 Answers  


Is sql a backend language?

0 Answers  


What do you mean by dbms? What are its different types?

0 Answers  


What is a sql select statement?

0 Answers  






write a procedure to print a statement or number not using "dbms_output.put_line" package.write a procedure instead of it using procdure name as "print" ex:- declare a number:=2; begin print(a); end; /* when U type above procedure 2 have to should be printed*/

2 Answers   iFlex,


What are the different dml commands in sql?

0 Answers  


What is the difference between the repeatable read and serializable isolation levels? : Transact sql

0 Answers  


Is it possible to pass parameters to triggers?

0 Answers  


How to avoid using cursors? What to use instead of cursor and in what cases to do so?

0 Answers  


What is the use of prepared statement?

0 Answers  


what is unique key constraint? : Sql dba

0 Answers  


Categories