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.
| Author |
Topic |
|
misterraj
Yak Posting Veteran
94 Posts |
Posted - 2009-07-06 : 00:59:00
|
| I have a query which will retrieve some 1000 records, select * from table1 where column = conditionI also need to retriev nth record from it, for example if the user passes 5, i need 5th record from this query. if the user passes 100 i need 100th record.is there any way to retrieve the nth record from a single querysomething like thisselect * from table1 where rownumber =n? |
|
|
khtan
In (Som, Ni, Yak)
17689 Posts |
Posted - 2009-07-06 : 01:00:42
|
[code]select *from ( select *, row_no = row_number() over (order by somecol) from table1 ) t where t.row_no = @n[/code] KH[spoiler]Time is always against us[/spoiler] |
 |
|
|
bklr
Master Smack Fu Yak Hacker
1693 Posts |
Posted - 2009-07-06 : 01:44:23
|
| see this linkhttp://sqlblogcasts.com/blogs/madhivanan/archive/2007/08/27/find-nth-maximum-value.aspx |
 |
|
|
|
|
|