14,503 questions
Hi @--
If I understand correctly, you can try this query.
;with CTE as(
select *,row_number()over(partition by groupid order by value1) as num1,
row_number()over(partition by groupid order by value2) as num2 from sourcetable)
select groupid,value1,value2 from CTE where num1 = num2;
Best regards, Percy Tang