Hi Folks,
I have a source table which looks like below
EMPID TYPE INTERNAL-ID
001 AA 001
001 BB 001
001 BB 053
001 CC 023
001 DD 009
002 AA 002
002 BB 045
002 CC 049
002 EE 034
003 AA 003
003 CC 044
003 BB 034
003 BB 036
Now i Have 2 Condition
Condition One:
If there is no EE TYPE take any one BB TYPE INTERNAL ID and insert as EE.
like for 001 we have to insert as 001 EE 053 or 001 EE 001
Condition two:
Each EMPID should have 5 TYPEs or Records i.e. AA,BB,CC,DD,EE
If any EMPID does Not have a TYPE i have to Insert it by taking the INTERNAL-ID for TYPE AA (only in EE type its different as states in condition one)
example : for 003 EMPID DD and EE TYPE records are Missing so i have to insert 2
records by taking AA INTERNAL ID as
003 DD 003
003 EE 034
So Final Output should be-
EMPID TYPE INTERNAL-ID
001 AA 001
001 BB 001
001 BB 053
001 CC 023
001 DD 009
001 EE 001
002 AA 002
002 BB 045
002 CC 049
002 DD 002
002 EE 034
003 AA 003
003 CC 044
003 BB 034
003 BB 036
003 DD 003
003 EE 034
Thanks
Ashiq