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.

Answer Posted / 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



Post New Answer       View All Answers


Please Help Members By Posting Answers For Below Questions

what's the difference between a primary key and a unique key? : Sql dba

1030


Explain how to use transactions efficiently : transact sql

955


What is denormalization in a database?

1029


how would you enter characters as hex numbers? : Sql dba

968


How do I use google cloud in sql?

1068


What is the usage of when clause in trigger?

1031


what are the different tables present in mysql? : Sql dba

957


What does partition by mean in sql?

944


How can you select unique records from a table?

1051


What is t-sql? : Transact sql

966


What are the different types of dbms?

994


What is full join?

931


What are data types in pl sql?

1125


What are the two types of cursors in pl sql?

1058


What is primary key sql?

1013