I have table like #D: CREATE TABLE #D(ID1 INT, ID2 INT) insert into #D SELECT 1,2 UNION SELECT 2,1 UNION SELECT 3,4 UNION SELECT 4,3 UNION SELECT 5,7 UNION SELECT 7,5 SELECT * FROM #D DROP TABLE #D but we think (2,1),(4,3),(7,5) are duplicated rows. How we can have a query only choose (1,2),(3,4),(5,7) for the results? Alterative, you can get something like (1,2), (4,3),(7,5) also fine. Anyone can help me for this case? for real case I have thousands row like this. Thanks.