One way to do it is using the row_number function. In my example, col1 and col2 are the distinct columns and col3, col4, col5 are the others. I arbitrarily chose to order by col3, col4, col5 and pick the first one if there are dups. You can tailor to your needs.;WITH cte AS( SELECT *, ROW_NUMBER() OVER (PARTITION BY col1,col2 ORDER BY col3,col4,col5) AS RN FROM YourTable)SELECT col1,col2,col3,col4,col5FROM cteWHERE RN = 1;