Answer the question
In order to leave comments, you need to log in
How to merge duplicate records in a database table, while summing one of the table fields?
You need to merge records with the same Pole_Id, Month, Year into one record, while adding their Count fields.
Answer the question
In order to leave comments, you need to log in
Since you haven't specified what to do with ID
, you can make a grouping request. Add its result to a copy of the table and swap them. Or filter the grouping result by the number of records COUNT(*) > 1
, delete by Pole_Id
and add amounts.
SELECT Pole_id, Month, Year, SUM(Count)
FROM [Table]
GROUP BY Pole_id, Month, Year
HAVING (COUNT(*) > 1)
Didn't find what you were looking for?
Ask your questionAsk a Question
731 491 924 answers to any question