There is some way to get the sum of a table called initial_number, by means of dates, to be more clear I want the year 2011 to show me the total initial_number of that year, the year 2012 show me the total of the initial_number and so on
SELECT granjas.nombre_granja,año_destete, SUM(numero_inicial) AS total FROM
formulario_precebo
INNER JOIN granjas ON granjas.id = formulario_precebo.granja_id WHERE
granja_id = 9 AND año_destete BETWEEN '2011' AND '2017'
ORDER BY total DESC;
The formula I am implementing brings me the whole sum between this range of year, but I want you to show me the sum is for each year.