In SQL Server, I have a table that includes a list of duplicate tasks. Those tasks have the same id and name, but each one of them has a different value in a third column. How can I pick duplicates that have the higher value in third column?
For example, I have:
task_id | task_name | third_column |
---|---|---|
1 | task1 | 4 |
1 | task1 | 2 |
2 | task2 | 5 |
2 | task2 | 7 |
I would like to have this result:
task_id | task_name | third_column |
---|---|---|
1 | task1 | 4 |
2 | task2 | 7 |
Please keep in mind I would like to retrieve all the columns. I have been trying to make the MAX function work, and I am able to get a list grouped by a specific column and that excludes the info from other columns, where I would like to keep info from each column.