This handily gives me a unique line number starting with 1 for each invoice line item. What I can't seem to remember is how do I get another number that increments for each invoice number. So, say the first 2 rows in my data set have the same invoice number, they would both need to be assigned number 1. The next 3 rows are a different invoice number. They need to be number 2. Etc...
Microsoft SQL Server* T-SQLSQL
Last Comment
Mark Wills
8/22/2022 - Mon
Russ Suter
ASKER
Perhaps to try and clarify my question. Here's a data example... The first column was easy to compute using the ROW_NUMBER() function as I stated above. What I don't know is how to get the right values into the last column labeled INVOICECOUNT and highlighted in yellow in the above image.
Jonathan Kelly
I would think you will need to store the last invoice number and compare it with the current inv number.
If its not equal then increment the invoice count.
Jonathan Kelly
perhaps a sql function that takes in the invoice number and outputs the invoice count