Jan 7, 2011 #1 raynalb Programmer Joined Jan 7, 2011 Messages 2 Location US My SQL is a little rusty. Suppose I have Table1 with fields X and Y: X Y -- -- A B A C B A How would I write the SQL to eliminate the 3rd row because it is a duplicate of the 1st row when reversed? Thanks, Ray
My SQL is a little rusty. Suppose I have Table1 with fields X and Y: X Y -- -- A B A C B A How would I write the SQL to eliminate the 3rd row because it is a duplicate of the 1st row when reversed? Thanks, Ray
Jan 7, 2011 1 #2 markros Programmer Joined May 21, 2007 Messages 3,150 Location US Code: select * from Table1 T1 where not exists (select * from Table1 T2 where T1.X = T2.Y and T1.Y = T2.X) Alternative solution Code: select X, Y from Table1 T1 EXCEPT select Y, X from Table1 T1 PluralSight Learning Library Upvote 0 Downvote
Code: select * from Table1 T1 where not exists (select * from Table1 T2 where T1.X = T2.Y and T1.Y = T2.X) Alternative solution Code: select X, Y from Table1 T1 EXCEPT select Y, X from Table1 T1 PluralSight Learning Library
Jan 7, 2011 Thread starter #3 raynalb Programmer Joined Jan 7, 2011 Messages 2 Location US Thanks markros. Worked great. Regards, Ray Upvote 0 Downvote