注册

sql语句求助

浮生 2024/12/05 336 1 已解决

update data_infant di
join (
SELECT
count(0) as high_risk_0to3_total, CURRENT_DATE create_date
from infant i
where
year(i.birthday) = year(current_date) and i.is_highrisk = 1 and i.status in (0,2)
) as temp
on temp.create_date = di.create_date
set
di.high_risk_visit_once_rate_0to3 = if(temp.high_risk_0to3_total>0,100*(di.high_risk_visit_once_0to3_total + di.high_risk_visit_twice_0to3_total)/temp.high_risk_0to3_total,100),
di.high_risk_visit_twice_rate_0to3 = if(temp.high_risk_0to3_total>0,100* di.high_risk_visit_twice_0to3_total/temp.high_risk_0to3_total,100)
where di.create_date = CURRENT_DATE and di.is_static = 0 and di.street_code = '-1';

为什么set后面的两个字段执行会报错?是哪里适配有问题吗,改成select这两个字段好像又没问题,update语句里的set有什么要求吗

回答 0
暂无回答
扫一扫
联系客服