[Solved] How to sum duplicated values in SQL [closed]


Assuming your table contains a field containing the year, and a field containing the price, you would simply use:

SELECT AcquisitionYear, SUM(Price) AS TotalPrice
FROM MyTable
GROUP BY AcquisitionYear

If your table contains a date field, you’d need to extract the year from this field using the YEAR() function:

SELECT YEAR(AcquisitionDate), SUM(Price) AS TotalPrice
FROM MyTable
GROUP BY YEAR(AcquisitionDate)

1

solved How to sum duplicated values in SQL [closed]