counter that resets at each new customer account record

Database
N/A

counter that resets at each new customer account record

hello and thank you for any help you can provide. I need to loop through a set of account numbers and I want a sequential counter on each. When I get to the next account number I want to reset the counter. For example say the rows in the account number column are 5521, 5521, 5521, 6760, 6670, 5622, 4444. I want to output 2 rows, the account number and the counter field with the following data (corresponding to the same order of accounts I provided): 1,2,3,1,2,1,1.

How can I do this?

Thx,

Scott
2 REPLIES
N/A

Re: counter that resets at each new customer account record

select acc_no,
row_number() over (partition by acc_no order by ??)
from tab

Dieter
N/A

Re: counter that resets at each new customer account record

Dieter,

Thank you very much!!!!!

-Scott