One thing you can do is write a SELECT that will always "sort" the names alphabetically: (Value1 will always be <= Value2)select Date, case when Value1 <= Value2 then Value1 else Value2 end as Value1, case when Value1 <= Value2 then Value2 else Value1 end as Value2from YourTable
That will make rows with the same two names match up.Then, using the above SQL in a derived table, you can do a simple group by :select Date, Value1, Value2from (the above SQL) agroup by Date, Value1, Value2