I have a table with a list of names, and I want to compose a query that will sort the names and then number each name starting with the first occurrence of a particular name, I also want the number sequence to start at 1 for the next name. Basically for duplicate records I have to start the sequence numbers. Below is an example of what I’m trying to do.
Table
Name
AAA
AAA
CCC
AAA
CCC
BBB
BBB
AAA
BBB
Query
Name Number
AAA 1
AAA 2
AAA 3
AAA 4
BBB 1
BBB 2
BBB 3
CCC 1
CCC 2
Table
Name
AAA
AAA
CCC
AAA
CCC
BBB
BBB
AAA
BBB
Query
Name Number
AAA 1
AAA 2
AAA 3
AAA 4
BBB 1
BBB 2
BBB 3
CCC 1
CCC 2
Comment