Find all pairs of distinct values in two columns

Write a SQL query to find all pairs of distinct values in two columns.

Problem

Given a table with two columns, write a SQL query to find all pairs of distinct values in the columns.
Input:
+----+-----+
| A  |  B  |
+----+-----+
| 1  |  2  |
| 2  |  1  |
| 3  |  4  |
| 4  |  3  |
+----+-----+
Output:
+----+-----+
| A  |  B  |
+----+-----+
| 1  |  2  |
| 3  |  4  |
+----+-----+

Solution

This solution is in SQL. Our A.I. can create solutions in multiple languages.
by sarastevens
SELECT DISTINCT A, B FROM table

/*

The solution above is optimal because it uses the DISTINCT keyword to remove duplicates.

*/

A.I. Evaluation of the Solution

The solution above is optimal because it uses the DISTINCT keyword to remove duplicates.

Evaluated at: 2022-11-22 06:16:06