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 is subquery? : Sql dba

1068


Can you sum a count in sql?

956


Are ddl triggers fired for ddl statements within a pl/sql code executed using the dbms.sql package?

1040


Does normalization improve performance?

982


Is sql similar to python?

919


How many types of tables are there?

901


What is the difference between union and union all command?

1009


How to process query result in pl/sql?

1062


What is varray in pl sql?

1008


What is left join in sql?

1006


what is clause? : Sql dba

1006


What is the difference between the conventional and direct path loads? : aql loader

1318


Is sql low level language?

963


How many functions are there in sql?

964


How to load data with sql*loader?

1000