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 / ammu

Hi Prakash Kumar,

this is the problem with rownum. In general never use = or
> with rownum. I will explain the reason.

Siuppose u hav 2 rowns in a table.

when u say select * from emp where rownum =2.

then 2 row will get selected ...but as soon as it gets
selected..since it is the only row in the selection its row
num will change to 1.

so this will return 0 rows.

similarly..

when u say rownum >1
2 row will get selected but as soon as it get selected its
rownum changes to 1.. so no rows selected again

Is This Answer Correct ?    1 Yes 1 No



Post New Answer       View All Answers


Please Help Members By Posting Answers For Below Questions

define sql update statement ? : Sql dba

1109


Show code of a cursor for loop.

1050


how to do backup entire database? : Transact sql

1129


How do I find sql profiler?

931


Is sql better than access?

1006


What are local and global variables and their differences?

1084


How to call a javascript function from pl sql?

1127


Can you have more than one key in a database?

930


What steps server process has to take to execute an update statement?

973


What does trigger mean in slang?

1044


how to use 'mysql' to run sql statements? : Sql dba

1040


What is a sql schema used for?

1092


What is data type in sql?

944


what are different types of collation sensitivity? : Sql dba

1060


what is 'mysqldump'? : Sql dba

1104