Write a SQL query to find all pairs of distinct values in two columns.
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 | +----+-----+
SELECT DISTINCT A, B FROM table /* The solution above is optimal because it uses the DISTINCT keyword to remove duplicates. */
The solution above is optimal because it uses the DISTINCT keyword to remove duplicates.
Evaluated at: 2022-11-22 06:16:06