query help

  • Hi

    Im trying to write query for:

    my table has millions of rows ..

    o/p should be only 50K rows ... and these rows should lie in any date range .

  • Do you mean some sort of pagination query kind of thing

    SELECT TOP 100 * FROM (SELECT

    ROW_NUMBER() OVER (ORDER BY Date) AS RowNumber,

    *

    FROM

    dbo.Table) myResults

    WHERE

    RowNumber > 2

  • I would need to see min and max date for these 50rows.

    More:

    requirement is to have any date range that can give me 50k records (these records should lie in this date range 🙂 )

  • This works as i need

    SELECT resultnr,timeinfo

    FROM (SELECT ROW_NUMBER() OVER (ORDER BY timeinfo ASC) AS Row,

    resultnr,timeinfo

    FROM my_table) tmp

    WHERE Row >1 and row <= 50

  • Post your table/index defintions

    and also see link below my signature to get faster response on your posts/queries.

    -------Bhuvnesh----------
    I work only to learn Sql Server...though my company pays me for getting their stuff done;-)

Viewing 5 posts - 1 through 4 (of 4 total)

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