Imagine the below table as A
col1 col2 col3 rank
1 2 n 5
1 2 n 6
2 3 a 3
While inserting below records from table B to table A, the rank column valus should be keep incrementing if the same records inserts.
Records in table B which gonna insert into A are
col1 col2 col3
1 2 n
2 3 a
The desired output in table A after the above records are inserted is,
col1 col2 col3 rank
1 2 n 5
1 2 n 6
1 2 n 7
2 3 a 3
2 3 a 4
Please help me how to acheive this.Thanks.
If the record in B are unique, then you could use a query like this
————–EDIT——————-
If B can have multiple records, you can use row_number() funcion with partition
————–END EDIT——————-
Note: i renamed the table: TestA and TestB
or with a JOIN like this