[HR] Symmetric Pairs

yozzum·2022년 9월 18일
0

SQL

목록 보기
14/25
select t1.x x1, t1.y y1
from functions t1
inner join functions t2
on t1.x = t2.y and t1.y = t2.x
group by t1.x, t1.y
having 1=1 
and count(*) > 1  -- if count = 1, it is self symmetric(x=y). There should be more than one self symmetric pairs 
or t1.x < t1.y -- for those symmetric pairs where x <> y
order by t1.x
profile
yozzum

0개의 댓글