I'm trying to use a cumulative result from one table where the date is one row before the row matching on the JOIN's a.date=b.date. Not all dates are present, so I can't assume the previous day will exist. I figure I need to use an offset on b.date in the formula (e.g. b.date[-1] or something). Here's the query as it is, which works except using the current date's row in TGlobalHistory instead of the date before.INSERT INTO TNaiveError(date, error) SELECT TRatings.date, SUM(POW(TRatings.rating-TGlobalHistory.csum/TGlobalHistory.ccount,2))/COUNT(TRatings.rating) FROM TRatings JOIN TGlobalHistory ON TGlobalHistory.date = TRatings.date GROUP BY TRatings.date;
Thanks!