Sure.  Just use something like this:

SELECT * FROM (Select * from sometable
                                Order by sortcolumn)
WHERE rownum>=1 and rownum<=10

This would return the first 1-10th rows of the query (sorted properly)

If you were not interested in sorting properly, you could just do:
SELECT * from sometable
WHERE rownum>=1 and rownum<=10

Of course, normally you would use ? instead of hardcoded values...

:-)  Hope this helps

----- Original Message -----
From: "Mindaugas Idzelis" <[EMAIL PROTECTED]>
To: "struts" <[EMAIL PROTECTED]>
Sent: Friday, June 15, 2001 9:57 AM
Subject: General DATABASE programming question


> This may be a little off topic, please forgive me. One of my
webapplications
> displays a group of results from a database query. These can be hundreds
of
> rows long. I would like to break these up into smaller sections to fit on
a
> page.
>
> My problem is, I don't want to run the entire query at once and save it to
> memory.
>
> PostgreSQL and MySQL have the LIMIT num,offset qualifier which does
exactly
> what I want. The problem is that I'm using MS SQL and it doesn't use the
> LIMIT keyword. Instead, it uses TOP and you can't supply an offset.
>
> My quetion: Is there anyway to specify an offset into a query using MS SQL
> Server? Thank you.
>
> --min
>
>

Reply via email to