此查询给出 1093 错误:
UPDATE values_table as outer_select
SET annual_change = sample_value - (
SELECT sample_value FROM values_table
WHERE date_sampled = DATE_SUB(outer_select.date_sampled, INTERVAL 1 YEAR)
);
我试图annual_change
为每一行设置等于当前行sample_value
减去去年的sample_value
.
数据不回溯到开始时间,那么缺少历史值怎么办呢?