I am trying to find out a solution for below case - I tried regular insert update logic and that does not solve.
Scenario
There will be data updates coming in and a table need to look at these updates and then decide one of the following. Table has customer and State along with its active status, State Rep and an alpha numeric unique key in it.

Incoming Data Scenarios:
- If a record (Customer & State combination) exist in the table with Active Status (1) then don’t do anything
- If a record (Customer, State) is coming in but it exist with inactive status (0) within the table, then insert the record and make it Active (1)
- If a Customer comes in with a different State then update the State and make the Rep column to Null
- If it’s a brand new customer , then insert the record and generate a new key for that row (with Active status=1)

Here is the desired result (Final format of the table after making the updates/inserts)
