Golgappa.net | Golgappa.org | BagIndia.net | BodyIndia.Com | CabIndia.net | CarsBikes.net | CarsBikes.org | CashIndia.net | ConsumerIndia.net | CookingIndia.net | DataIndia.net | DealIndia.net | EmailIndia.net | FirstTablet.com | FirstTourist.com | ForsaleIndia.net | IndiaBody.Com | IndiaCab.net | IndiaCash.net | IndiaModel.net | KidForum.net | OfficeIndia.net | PaysIndia.com | RestaurantIndia.net | RestaurantsIndia.net | SaleForum.net | SellForum.net | SoldIndia.com | StarIndia.net | TomatoCab.com | TomatoCabs.com | TownIndia.com
Interested to Buy Any Domain ? << Click Here >> for more details...


how to retrieve last tree records from table?
select *from emp where rownum > (select count(*)-3 from
emp);
i am using this query to get last three records from table
but its not giving any output, so please tell me what is the
error in this query.

Answers were Sorted based on User's Feedback



how to retrieve last tree records from table? select *from emp where rownum > (select count(*)-3..

Answer / ajit nayak

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

Is This Answer Correct ?    0 Yes 0 No

how to retrieve last tree records from table? select *from emp where rownum > (select count(*)-3..

Answer / swastik

SELECT * FROM
(
SELECT * FROM Emp
ORDER BY ROWNUM DESC
)
WHERE ROWNUM <= 3;

Is This Answer Correct ?    0 Yes 0 No

how to retrieve last tree records from table? select *from emp where rownum > (select count(*)-3..

Answer / ashwin

if emp table is having 10 records then
1)for first 6 write

select ename,sal from(select ename,sal from emp order by sal
desc) where rownum <7;

2)for last 3 write

select ename,sal from(select ename,sal from emp order by sal
desc) where rownum >7;

Is This Answer Correct ?    2 Yes 3 No

how to retrieve last tree records from table? select *from emp where rownum > (select count(*)-3..

Answer / sanjay

SELECT ROWNUM AS rank, employee_id
FROM (SELECT employee_id
FROM employees
ORDER BY employee_id DESC)
WHERE ROWNUM<=3

Is This Answer Correct ?    0 Yes 1 No

how to retrieve last tree records from table? select *from emp where rownum > (select count(*)-3..

Answer / shekaran04

Hi,
First thing you cannot use " ROWNUM > (somthing) "
And to get last three records...

Select *from emp
minus
Select *from emp where rownum <(select Count(*) from emp)-
3;

Good Luck...

Is This Answer Correct ?    0 Yes 1 No

how to retrieve last tree records from table? select *from emp where rownum > (select count(*)-3..

Answer / mohammed shahid

select distinct TOP3 from emp order by rownum desc;

Is This Answer Correct ?    2 Yes 8 No

Post New Answer

More SQL PLSQL Interview Questions

What is the benefit of foreign key?

0 Answers  


How to use sql statements in pl/sql?

0 Answers  


how to increment dates by 1 in mysql? : Sql dba

0 Answers  


what is the difference between trigger and constraint?

3 Answers   HSBC,


Can we use out parameter in function?

4 Answers   Infosys,


Can we insert data into materialized view?

0 Answers  


how to retrieve last tree records from table? select *from emp where rownum > (select count(*)-3 from emp); i am using this query to get last three records from table but its not giving any output, so please tell me what is the error in this query.

16 Answers  


How does join work in sql?

0 Answers  


Can we perform dml in function?

0 Answers  


what is the purpose of update command in oracle?

7 Answers   MBT,


How do I tune a sql query?

0 Answers  


how to eliminate null values in a column i.e table vlaues 1 2 3 NULL 3 4 1 5 NULL i want output like this 1 2 3 3 4 1 5 i dnt want to use nvl is null and i dnt want replace the NULL value with any value i.e nvl(col,o);

11 Answers   Satyam,


Categories