运行此查询后,我收到一条错误消息,指出无效使用组功能。我很确定它在 case 语句之后,我需要一个“AS 金额”或“AS i.amount”,但 mySQl 也不喜欢其中任何一个。有什么建议么?
update INVITATION AS i
LEFT JOIN REGISTRATION AS r on i.id=r.INVITATION_id
LEFT JOIN FUNDING AS f on r.id=f.REGISTRATION_id
SET i.funding_travel_amount = SUM(case
when f.category = "Other" then sum(amount)
when f.category = "Airfare" then sum(amount)
when f.category = "Mileage" then sum(amount)
else 0 end), i.funding_travel = "Custom"
WHERE i.funding_hotel = "Prepaid"
and i.funding_travel = "None"
and i.funding_per_diem = "None"
and (f.category = "Other" OR f.category ="Airfare" OR f.category= "Mileage")
and f.id is not null;