Need an prgramming advise

  • Hi,

    I have a solution for my problem, but I would need an advise, if anyone has a better solution.

    I have to retrieve from sql records between the 4th and the 10 th for example. I can't use something like 'where id between 4 and 10' because the data is sorted after some criteria.

    I am thinking to obtain a numbered query , using a function that returns like n=n+1,

    and:

    select X.field1,X.field2 from (select function(n) as number, field1, field2 from table) as X where X.numer between 4 and 10.

    Any better idea?

    thanks


    Daniela

  • Hi Daniela..

    Check out the new ROW_NUMBER operator.  It should give you just the functionality you're looking for.

    Hope this helps..


    Take care..

    - Ward Pond
    blogs.technet.com/wardpond

  • Wow. I knew I was complicating stuffs.

    Very elegant and simple solution.

    Thank you!


    Daniela

Viewing 3 posts - 1 through 2 (of 2 total)

You must be logged in to reply to this topic. Login to reply