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 |
|
alto
Starting Member
3 Posts |
Posted - 2008-08-17 : 10:09:22
|
| I need help for a query, Suppose in a table there are a million data. I need to select rows such as row number 5 to 13. Plz give the SQL quey for SQL server 2005. |
|
|
ayamas
Aged Yak Warrior
552 Posts |
Posted - 2008-08-17 : 10:35:26
|
| DECLARE @Sample TABLE (id int identity(1,1),names varchar(3))insert into @sampleselect 'a' union allselect 'b' union allselect 'c' union allselect 'd' union allselect 'e' union allselect 'f' select * from (select row_number() over(order by id) as rowid,names from @sample)t where rowid between 2 and 5 |
 |
|
|
GilaMonster
Master Smack Fu Yak Hacker
4507 Posts |
Posted - 2008-08-17 : 10:46:42
|
| Bear in mind that SQL has no concept of row ordering without an order by of some form. So, if you want the 5th row, you need to know the 5th row when ordered by what.--Gail ShawSQL Server MVP |
 |
|
|
SwePeso
Patron Saint of Lost Yaks
30421 Posts |
Posted - 2008-08-17 : 12:47:19
|
SELECT TOP 9 * FROM (SELECT TOP 13 * FROM Table1 ORDER BY Col1) AS d ORDER BY Col1 DESC E 12°55'05.25"N 56°04'39.16" |
 |
|
|
|
|
|