By using db<>fiddle, you agree to license everything you submit by Creative Commons CC0.
select version();
version() |
---|
5.5.62 |
CREATE TABLE test( id INT, a INT, b INT );
INSERT INTO test VALUES
(1,1,3),(2,2,3),(3,3,1);
SELECT * FROM test;
id | a | b |
---|---|---|
1 | 1 | 3 |
2 | 2 | 3 |
3 | 3 | 1 |
SELECT least(a, b) , greatest (a,b)
FROM test
GROUP BY least(a, b) , greatest (a,b)
least(a, b) | greatest (a,b) |
---|---|
1 | 3 |
2 | 3 |