Skip to content
Advertisement

SQL: Retrieve Distinct for different columns

I have the following scenario:

In a SQL-Table I have the following columns:

The first two rows are kind of referencing to the same records because they contain the same values for row1 and row 2 but swapped.

Is there an sql-way of only retrieving one of those two colums?? so that in the end I receive the following result:

THX

Advertisement

Answer

A simple method is:

This has the advantage of preserving the original rows. If you don’t care about the ordering:

User contributions licensed under: CC BY-SA
3 People found this is helpful
Advertisement