我想從reg_data3的avg_month_val1表中添加平均月份值,但有錯誤查詢無法正常工作。目前的每月平均值不應插入到avg_month_val table.error是具有子句中的未知列名稱。請幫我現在的月份平均值不應該傳遞到平均值表
INSERT IGNORE INTO `clima_data`.`avg_month_val1` (
`year` , `month` , `evep` , `sunshine_hrs` ,
`rainfall` , `max_temp` , `min_temp`)
SELECT
year(str_to_date(date, '%Y-%m-%d'))as year,
month(str_to_date(date, '%Y-%m-%d'))as month,
round(avg(evep),2),
round(Avg(sunshine_hrs),2),
round(sum(rainfall),2),
round(AVG(max_temp),2),
round(avg(min_temp),2)
FROM reg_data3
GROUP BY
year(str_to_date(date, '%Y-%m-%d')),
month(str_to_date(date, '%Y-%m-%d'))
HAVING
(year(str_to_date(date , '%Y-%m-%d')) <> year(CURRENT_TIMESTAMP)
AND month(str_to_date(date , '%Y-%m-%d')) <> month(CURRENT_TIMESTAMP))
ORDER BY 1 Desc;
這個問題沒有答案 – SasinduRHN