|
On the second look, my update can be simplified a bit:Yup, this does the trick. You can use the ORDER BY clause to change the sequence the numbers are incremented, and it updates perfectly. I have to remember the UPDATE using a subselect technique.
UPDATE myFile A SET A.SEQ_# = (SELECT ORDINAL_NUMBER FROM (SELECT FISCAL_YEAR,CONTROL_GROUP,SOURCE_CODE, ROW_NUMBER() OVER(ORDER BY FISCAL_YEAR) AS ORDINAL_NUMBER
FROM myFile
GROUP BY FISCAL_YEAR,CONTROL_GROUP,SOURCE_CODE) B
WHERE A.FISCAL_YEAR = B.FISCAL_YEAR AND A.CONTROL_GROUP = B.CONTROL_GROUP AND A.SOURCE_CODE = B.SOURCE_CODE)
As an Amazon Associate we earn from qualifying purchases.
This mailing list archive is Copyright 1997-2024 by midrange.com and David Gibbs as a compilation work. Use of the archive is restricted to research of a business or technical nature. Any other uses are prohibited. Full details are available on our policy page. If you have questions about this, please contact [javascript protected email address].
Operating expenses for this site are earned using the Amazon Associate program and Google Adsense.