I have data like below: (columns Name1 and Name2) as a result of another query.
Name1 Name2
A B
B A
However, any such pairings should actually be considered just one, and should be only reported as A B (A comes before B , alphabetically sorted)
How do I do it in Oracle / PlSQL?
You could do something like this:
Which should work and is quite simple, but is not as efficient as:
or just:
I have not considered NULLs in these queries. You’d have to modify the <= comparisons to take these into account, if the columns are nullable.