Skip to content
Advertisement

SQL Server: remove duplicates in exchangeable columns

I have this query:

It returns a result like this:

As the following records for my use considered duplicate (if they have same ReceiveDate), I want to remove one of them, and achieve this result:

Advertisement

Answer

Using the <> operator will create these (logical) duplicates. Instead, you can decide which column you want to have the lower ID and use < or > accordingly. E.g.:

User contributions licensed under: CC BY-SA
5 People found this is helpful
Advertisement