Symmetric Pairs

  • + 0 comments

    My solution:

    with cte1 as (select x, y, row_number() over( order by x) as ro_num from Functions), cte2 as (select x, y from cte1 oq where y in (select x from cte1 where ro_num != oq.ro_num and y = oq.x)) select top((select count(*) from cte2)/2) x, y from cte2 order by x;