Sql to select the rows and ignore the duplicate userid in SQL Server [closed]
One method is aggregation: select col1, col2, max(col3), max(col4) from t group by col1, col2; For your sample data it is easier to just filter out NULL values: select t.* from t where col3 is not null;