Results 1 to 2 of 2

Thread: MySQL >>MS SQL transisiton problem.

  1. #1

    Thread Starter
    PowerPoster Arc's Avatar
    Join Date
    Sep 2000
    Location
    Under my rock
    Posts
    2,336

    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.


  2. #2
    Hyperactive Member goatsucker's Avatar
    Join Date
    Dec 2002
    Location
    Leeds, England
    Posts
    283
    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
  •  



Click Here to Expand Forum to Full Width