Symmetric Pairs

  • + 0 comments

    In this sql, I can't find the condition that we have to write only one row about same diagonal pairs this sql is answer. but i can't understand why i have to use group by `with cte as ( select x, y, row_number() over (order by x) as rn from functions ) select f1.x, f1.y from cte f1 join cte f2 on f1.x = f2.y and f1.y = f2.x and f1.rn != f2.rn where f1.x <= f1.y group by f1.x, f1.y