I\'m trying to sum values from duplicates rows (with the same ID, Month and Person) in multiple columns to the first or the last duplicate row. Then delete the duplicate rows ex
SELECT ID, Month, Person, SUM(Value1) as SumValue1, SUM(Value2) AS SumValue2
FROM db.Hours
GROUP BY ID, Month, Person
I am not sure why you are looking at this as two steps etc. There is no removal of duplicates etc. this is a scenario for Group By Aggregation. Where you group like rows and summarize the value columns. The only reason you would need to make this a multi step operation would be if one of your value columns will be considered within your grouping e.g. ID, Month, Person, and Value1. In your case you simply need to group by ID, Month, Person and do the aggregation for Value1 and Value2.