Skip to content

Instantly share code, notes, and snippets.

@Shaddyjr
Created July 17, 2019 05:20
Show Gist options
  • Save Shaddyjr/8b1ac948ec747b8d3663f06e13fb0a0f to your computer and use it in GitHub Desktop.
Save Shaddyjr/8b1ac948ec747b8d3663f06e13fb0a0f to your computer and use it in GitHub Desktop.
-- https://dba.stackexchange.com/questions/161901/select-pairs-a-b-excluding-b-a-with-same-value
SELECT
p1.Id,p2.Id,p1.Name
FROM Pairs p1
JOIN Pairs p2
ON p1.Name = p2.Name
AND p1.Id < p2.Id
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment