i have following tables (Table: avg_month_val1)
year
month
evep
sunshine_hrs
rainfall
max_temp
min_temp
and
(Table: reg_data3)
id
date
time
rainfall
evep
max_temp
min_temp
sunshine_hrs
i wan to up date avg_month_val1 table using reg_data3 i follow How do you update multiple fields from another table in mysql?
here is my query
UPDATE `avg_month_val1` a,`reg_data3` b SET
a.`year`=YEAR(b.`date`),
a.`month`=MONTH(b.`date`),
a.`evep`=ROUND(AVG(b.evep),2),
a.`max_temp`=ROUND(AVG(b.max_temp),2),
a.`min_temp`=ROUND(AVG(b.min_temp),2) ,
a.`rainfall`=ROUND(SUM(b.rainfall),2),
a.`sunshine_hrs`=ROUND(AVG(b.sunshine_hrs),2)
WHERE a.`year`=YEAR(b.`date`)
but it gives following error
Error Code: 1111
Invalid use of group function
how i accomplish this
year. Suppose that the tableacontains 12 records for a given year, which records should be updated ? It also would be helpfull if you provided an example of source data and expected results.