Maya Shechter Maya Shechter - 1 year ago 58
SQL Question

SQL - Delete repeated rows in table

I need to delete the repeated row-

I have this table-

source
The result that I need-

result

*keep only one combination of 2 column (the order is not important)

Thanks! (:

Answer Source

My interpretation of the spec "keep only one combination of 2 column, [column] order not important":

SELECT col1, col2
FROM t
WHERE col1 <= col2
UNION
SELECT col2, col1
FROM t
WHERE col1 > col2;