|
-
Jan 15th, 2003, 11:28 AM
#1
Thread Starter
PowerPoster
MySQL >>MS SQL transisiton problem.
In MySQL you can use the limit function to return a subset of a query:
SELECT * FROM names LIMIT (5,15)
What's an easy way to do it in SQL Server? (I know somebody is going to say use top, as in SELECT TOP 10 * FROM names, but that gets the top 10, not items 5 through 15...) Any other suggestions?
Thanks!!
-We have enough youth. How about a fountain of "Smart"?
-If you can read this, thank a teacher....and since it's in English, thank a soldier.

-
Jan 15th, 2003, 11:53 AM
#2
Hyperactive Member
I would think that if you need to do this and don't have a convenient field with which to limit your selection then you have your database design wrong.
Having said that you can use this kind of query to add a running total field
Code:
SELECT A.Field1, count(B.Field1)
FROM Table a, Table B
Where B.Field1 <= A.Field1
Group by A.Field1;
But this may be slow on large tables. you could then use this running total field to select on instead of the LIMIT function
After all "Rust Never Sleeps"
Posting Permissions
- You may not post new threads
- You may not post replies
- You may not post attachments
- You may not edit your posts
-
Forum Rules
|
Click Here to Expand Forum to Full Width
|