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)

  • patelmohamad (10/16/2012)


    Thanks Lowell for instant reply,

    This is my predication, not the actual data

    , actual data is differ from my Example

    in my data it gives me lot of no's 1,2,3.......n or sometime it gives only 2, 3 no's

    in such case i cant specify the RowId.

    any other technique on the same query.

    Thanks once again.

    so far, I have no idea;

    can you explain WHY the row_number could/should reset?

    if you can explain that, we could change the partition by predicate to match the desired logic.

    my problem, when reviewing the sample data in the screenshot, was it looked like you wanted to break based on # or rows (20 rows, then 5 rows, then 5 rows)

    and not break based on something in the data itself.

    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!