Home Forums SQL Server 2005 Development Reset the Number by Column Value using ROW_NUMBER() OVER (PARTITION BY Field) RE: Reset the Number by Column Value using ROW_NUMBER() OVER (PARTITION BY Field)

  • patel i see what you are asking, but i don't see the data reflecting something that allows it to beswitched like that;

    about all i can suggest is a UNION and statements that reflect the desired ranges.

    ;

    SELECT

    ROW_NUMBER() OVER (PARTITION BY RowNumber order by RowID)

    ,RowID

    ,TodaysDate

    ,Name

    ,RowNumber

    where rowid <=20

    UNION ALL

    SELECT

    ROW_NUMBER() OVER (PARTITION BY RowNumber order by RowID)

    ,RowID

    ,TodaysDate

    ,Name

    ,RowNumber

    where rowid > 20

    and rowid <= 25

    UNION ALL

    SELECT

    ROW_NUMBER() OVER (PARTITION BY RowNumber order by RowID)

    ,RowID

    ,TodaysDate

    ,Name

    ,RowNumber

    where rowid > 25

    and rowid <= 30

    Lowell


    --help us help you! If you post a question, make sure you include a CREATE TABLE... statement and INSERT INTO... statement into that table to give the volunteers here representative data. with your description of the problem, we can provide a tested, verifiable solution to your question! asking the question the right way gets you a tested answer the fastest way possible!