add batch remove batch split batch comment selection show hidden batches hide batch highlight batch
db<>fiddle
donate feedback about
By using db<>fiddle, you agree to license everything you submit by Creative Commons CC0.
WITH yourTable AS (
SELECT 'john' AS first, 'Keats' AS last UNION ALL
SELECT 'Ray', 'Owano' UNION ALL
SELECT 'Keats', 'john' UNION ALL
SELECT 'Joseph', 'taylor' UNION ALL
SELECT 'Owano', 'Ray'
)

SELECT DISTINCT
CASE WHEN first < last THEN first ELSE last END AS first,
CASE WHEN first < last THEN last ELSE first END AS last
FROM yourTable;



first last
john Keats
Joseph taylor
Owano Ray