I have a table with symmetric relation, e.g. 10 is friend with 123 and 123 is friend with 10
The table looks like this:
How do I select every pair only once ?
i.e.:
The table looks like this:
Code:
with tab(personnr, personnr1) as (
values(10, 123),
(123,10),
(20,456),
(456,20)
)
select * from tab
....+....1....+....2....+....3
PERSONNR PERSONNR1
10 123
123 10
20 456
456 20
******** End of data ********
How do I select every pair only once ?
i.e.:
Code:
PERSONNR PERSONNR1
10 123
20 456