I have a table with data of different months. I want to update 'PUC_AVG_UCOST' with data from the same table where the date is max date My sql is as follows
update lty_prd_u_cost a
set PUC_AVG_UCOST=
( SELECT PUC_AVG_UCOST
from lty_prd_u_cost b
where PUC_DATE=
( SELECT max(c.PUC_DATE)
from lty_prd_u_cost c
where b.PUC_PRD_NAME=c.PUC_PRD_NAME
)
)
where a.PUC_AVG_UCOST=0
and puc_date='2021-08-31'
There is the following error
[Err] 1242 - Subquery returns more than 1 row
Kindly help me correct it
IF I can not find a value for the current month the value of the immediate past month will be taken as the current month Value.


UPDATE, correct? What should the data look like after?