I have a TableA that has an TransID I created to keep certain records together. Once those records have been reviewed, I need to assign TableA.DocNum to TableB.DocNum value +1
TableA
| TransId | DocNum |
|---|---|
| 5 | |
| 5 | |
| 6 | |
| 6 | |
| 7 | |
| 7 |
TableB
| DocNum |
|---|
| 0000001 |
TableA Finished Result
| TransId | DocNum |
|---|---|
| 5 | 0000002 |
| 5 | 0000002 |
| 6 | 0000003 |
| 6 | 0000003 |
| 7 | 0000004 |
| 7 | 0000004 |
TableB Finished Result
TableB
| DocNum |
|---|
| 0000004 |
I have tried a loop but it didn't seem to work.
Here is an approach using dense_rank()
Example or dbFiddle
Results