Changing the JOIN condition slightly will achieve what you want..
Instead of:
ON (mytable.letter = self.letter and mytable.number != self.number)
use
ON (mytable.letter = self.letter and mytable.number > self.number)
This will only include combinations where self.number
is greater than mytable.number
which in effect restricts the results to one valid ordering of each combination...