The case when statement queries a single piece of data. If you want to check the sum of a certain value under the condition, for example, I want to check the sum of price when is_check=1:
应该用SUM(CASE is_check WHEN 1 THEN price END) AS checkPrice
而不是CASE is_check WHEN 1 THEN SUM(price) END AS checkPrice
select sum(case is_check when 0 then price end) AS noCheckPrice,
sum(CASE is_check WHEN 1 THEN price END) AS checkPrice,
SUM(price) as totalPrice
from t_subsidy_record