Help Please: Need to assign a sequence number for each group

  • Hello Experts,

    Is there something like an Identity that resets for each group?

    In the sample table below, I need to assign the seq#.

    I was thinking of using the identity() function into a #temp table, but that will mean doing it for each same group. did not like that idea, so I consult with the experts. Any help will be greatly appreciated.

    codeseq#

    A 1

    A 2

    A 3

    B 1

    B 2

    C 1

    D 1

    D 2

    Best,

    Michael

  • There's the Row_Number() function. Have you looked into using that?

    - Gus "GSquared", RSVP, OODA, MAP, NMVP, FAQ, SAT, SQL, DNA, RNA, UOI, IOU, AM, PM, AD, BC, BCE, USA, UN, CF, ROFL, LOL, ETC
    Property of The Thread

    "Nobody knows the age of the human race, but everyone agrees it's old enough to know better." - Anon

  • row_number() worked very well. guess, I'm becoming rusty. Thanks very much!

  • You're welcome.

    - Gus "GSquared", RSVP, OODA, MAP, NMVP, FAQ, SAT, SQL, DNA, RNA, UOI, IOU, AM, PM, AD, BC, BCE, USA, UN, CF, ROFL, LOL, ETC
    Property of The Thread

    "Nobody knows the age of the human race, but everyone agrees it's old enough to know better." - Anon

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

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