I'm trying to find the average score received by films between a certain time
SELECT SUM (score * ?) / SUM(?) AS AGGSCO
FROM movie, casting
INNER JOIN casting
WHERE movie.id = casting.movieid
AND yr BETWEEN 1930 AND 1939;
Instead of the question marks, I think I would need the number of occurrences. Following this I would need to repeat the code to find the average between 40 and 49 and then 50 to 59. Is there a loop that I can use or would I need to rewrite the code? Thanks for any advice!
ps: I'm using squirrel, not mysql so the syntax may differ