I am using the following code to calculate a running average:
SELECT AVG(close) FROM daily
ORDER BY datum DESC
for a 50-day average. However, it doesn't seem to work. I can change
20. The result is always the same. Is the
LIMIT just a visual limit maybe?
LIMIT restricts your result set, not the set you're averaging over. You'd want something like
SELECT AVG(close) FROM ( SELECT close FROM daily ORDER BY datum DESC LIMIT 50 )