'Deduplicate table data based on column value in another row

I have a table containing two columns src & dest, the data looks like this in the table:

table data

The requirement here is to deduplicate the data such that only one record exists where the dest column has a value populated as a src column or no value at all in the src column.

For example for the above data, below output should be shown by the sql query:

output data



Solution 1:[1]

Not sure. This may get you what you want:

select * from T
where src  not in (select dest from T)
   or dest not in (select src  from T);

Sources

This article follows the attribution requirements of Stack Overflow and is licensed under CC BY-SA 3.0.

Source: Stack Overflow

Solution Source
Solution 1 shawnt00