SQL combine multiple identifiers to create a group id for duplicate records
I'm working on a problem in Oracle that I'm struggling to solve 'elegantly'. I have a data extract with three different identifiers: A, B, C Each identifier may appear in more than one row, and each row may have one or more of these three identifiers (i.e the column is populated or null). I want to be able to group all records that have any combination of either A, B or C in common and assign them the same group id. Extract table showing what the eventual groups should be: Rownum | A | B | C | End group 1 p NULL NULL 1 2 p r NULL 1 3 q NULL NULL 2 4 NULL r NULL 1 5 NULL NULL s 2 6 q NULL s 2