Select unique pairs in self join
Change !=
to <
in your WHERE clause to ensure that the lowest ID always comes first:
WHERE b1.Id < b2.Id
Change !=
to <
in your WHERE clause to ensure that the lowest ID always comes first:
WHERE b1.Id < b2.Id