I need to check the sequence number generated of the client per risk , per policy ( E.g. starts at 1 for each risk and is incremented by 1 for each client) in table1.
Assign sequence number 1 if the Client is having the Role_ID as ‘A’ in Table2 and assign 2 if the Client is having Role_id as ‘B’ .
After that table 1 will look like
policy risk Risk_Sequence_No Client_Id Tab2.role_id
---------------------------------------------------------------------------------------
989898989 1 1 1000000001 A
989898989 1 2 1000000002 B
989898989 2 1 1000000001 A
989898989 2 2 1000000002 B
989898989 3 1 1000000001 A
170023233 1 1 1000000004 A
170023233 1 2 1000000005 B
Table 2 :
policy Client_Id role_id
989898989 1000000001 A
989898989 1000000002 B
170023233 1000000004 A
170023233 1000000005 B
role_idin your example.