select a set of rows depending on a row number

select a set of rows depending on a row number

Post by Rujuta Gan » Thu, 18 Nov 2004 16:40:08


Hi Everybody,

I am using the SQL server 2000 and i want to fetch set of rows between
suppose record number 10 to record number 20. This will fetch the records
from 10 to 20.

If there is any way to perform this task. does SQL support any inbuilt
functionality for the same like Oracle supports "ROWNUM".

It is extremely needed for me. Please help me out.

If i m not clear please ask without hesitation.
Thanking in advance,
Ruju
 
 
 

select a set of rows depending on a row number

Post by David Port » Thu, 18 Nov 2004 16:50:54

If you Google for ROWNUM in this group you'll find that various options have
been discussed many times. If this is for paging a result set then see:
http://www.yqcomputer.com/

--
David Portas
SQL Server MVP

 
 
 

select a set of rows depending on a row number

Post by Rujuta Gan » Fri, 19 Nov 2004 13:41:21

Hi David,

I m really thankful to u but the problem is I have already searched and I
could not found anything. It seems that there is nothing like ROWNUM in SQL
server 2000. what I need is I want to fetch records from 10 to 20 from the
table.

Uptil now I have not found anything for the same. This is available in
Oracle but not in SQL. If u know any other way to do this thing please tell
me.

Again thanks for ur suggestion.
Ruju
 
 
 

select a set of rows depending on a row number

Post by Steve Kas » Fri, 19 Nov 2004 16:08:26

Did you read the aspfaq article? The simple solutions with TOP or
ROWCOUNT should help you:

select top 11 *
from (
select top 20 *
from yourTable
order by <whatever determines the row order you want> asc
) T
order by <same as before> desc

or

set rowcount 11
go
select * from (
select top 20 *
from yourTable
order by <whatever determines the row order you want> asc
) T
order by OrderID desc
go
set rowcount 0

Steve Kass
Drew University
 
 
 

select a set of rows depending on a row number

Post by Dennis Red » Fri, 19 Nov 2004 22:32:15

In SQL Server fetching a specific "row number" is not defined by design.
Use an appropriate clustered primary key and look at the references already
given in this thread.

hope this helps.

dlr



SQL
tell