dupes holds customer records landed from several systems (source). Master-data rules say which system wins: the source_priority lookup gives each known source a rank (priority 1 = most trusted).
Keep one row per customer:
01the row from the customer's most trusted source;
02among that source's rows, the latest by loaded_ts.
A source missing from source_priority is less trusted than every listed source — but if it's all a customer has, that customer still gets a row. The trusted row wins even when it is older or has blanks.
Sort by customer_id.