Please start any new threads on our new site at https://forums.sqlteam.com. We've got lots of great SQL Server experts to answer whatever question you can come up with.

 All Forums
 General SQL Server Forums
 New to SQL Server Programming
 How can we get

Author  Topic 

boreddy
Posting Yak Master

172 Posts

Posted - 2008-08-17 : 23:50:51
I have 20 records in my table and i want to display 11th record from the table.

that is leaving first 10 records and then fetching the 11 th record.
Please give me the query for the same.
Thank you.

khtan
In (Som, Ni, Yak)

17689 Posts

Posted - 2008-08-17 : 23:59:42
if you are using SQL Server 2005

select *
from
(
select *, row_no = row_number() over (order by somecol)
from sometable
) t
where row_no = 11


EDIT : changed from row_no >= 11 as OP wants 11th record only


KH
[spoiler]Time is always against us[/spoiler]

Go to Top of Page

visakh16
Very Important crosS Applying yaK Herder

52326 Posts

Posted - 2008-08-18 : 00:01:03
SELECT Top 1 * FROM (SELECT TOP 11 * FROM YourTable ORDER BY PKCol) t ORDER BY t.PKCol DESC
Go to Top of Page

madhivanan
Premature Yak Congratulator

22864 Posts

Posted - 2008-08-18 : 04:11:44
http://sqlblogcasts.com/blogs/madhivanan/archive/2007/08/27/find-nth-maximum-value.aspx

Madhivanan

Failing to plan is Planning to fail
Go to Top of Page
   

- Advertisement -