April 24, 2010 at 8:59 am
how to retrive last 10 record form emp table?
April 24, 2010 at 9:31 am
Define 'last'
If you mean 'most recently entered', then you need some column that shows the order entered. Date inserted or an identity column. Order by that desc and use TOP
If you mean last 10 ordered by a specific column, then order by that column desc and use TOP
Gail Shaw
Microsoft Certified Master: SQL Server, MVP, M.Sc (Comp Sci)
SQL In The Wild: Discussions on DB performance with occasional diversions into recoverability
April 24, 2010 at 12:03 pm
select top 10 * from TableName order by ColumnName desc
This will give you last 10 records when ordered by columnName
:hehe:
April 24, 2010 at 12:05 pm
if u have autogenerated/ identity EmpID
select top 10 * from emp order by EmpID desc
Viewing 4 posts - 1 through 3 (of 3 total)
You must be logged in to reply to this topic. Login to reply