标签: c# mysql sql sql-server linq
我想知道当INVOICE_ITEM_ID列= 14时,如何使此表中此边框列中的值增加,当它更改为15时,边界表中的值再次从1开始,并以下一个1和等等
答案 0 :(得分:2)
假设您正在使用ROW_NUMBER,那么您正在寻找SELECT InvoiceNumber, INVOICE_ITEM_ID, SerialNumber, ROW_NUMBER() OVER(PARTITION BY INVOICE_ITEM_ID ORDER BY SerialNumber) AS RowNumber FROM table_name ORDER BY INVOICE_ITEM_ID,SerialNumber
ROW_NUMBER
SELECT InvoiceNumber, INVOICE_ITEM_ID, SerialNumber, ROW_NUMBER() OVER(PARTITION BY INVOICE_ITEM_ID ORDER BY SerialNumber) AS RowNumber FROM table_name ORDER BY INVOICE_ITEM_ID,SerialNumber
{{1}}