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 |
|
Vijaykumar_Patil
Posting Yak Master
121 Posts |
Posted - 2007-09-13 : 09:31:03
|
| Hi is there a way to get the nth row in a select query?Necessity is the mother of all inventions! |
|
|
ValterBorges
Master Smack Fu Yak Hacker
1429 Posts |
Posted - 2007-09-13 : 09:47:20
|
| create table #tempxyz (rowid int identity(1,1),col1 int, col2 char)insert into #tempxyz(col1,col2)select col1,col2 fromtablexyzorder by col1 asc, col2 descselect col1,col2 from #tempxyz where rowid = nthrowdrop table #tempxyzPS: If anyone is interested in a SQL Server job in Connecticut with excellent pay please send me a resume to ValterBorges@msn.com |
 |
|
|
madhivanan
Premature Yak Congratulator
22864 Posts |
Posted - 2007-09-13 : 09:52:01
|
It depends on how you define nth row MadhivananFailing to plan is Planning to fail |
 |
|
|
SwePeso
Patron Saint of Lost Yaks
30421 Posts |
Posted - 2007-09-13 : 09:52:32
|
Or, if using SQL Server 2005, make use of the new ROW_NUMBER() function. E 12°55'05.25"N 56°04'39.16" |
 |
|
|
X002548
Not Just a Number
15586 Posts |
|
|
|
|
|