sum中的case 语句包含子查询的改如何处理?
CCC的 2015-10-19 09:34:51 select op_ymd,M.depart_id, D.depart_name,
Sum(Case when MealType=0 and Kind=1 and clock_id in (select clock_id from clocks where dinroom_id='1') then 1 else 0 end) OneCount,
Sum(Case when MealType=0 and Kind=1 and clock_id in (select clock_id from clocks where dinroom_id='2') then 1 else 0 end) OneCount2,
Sum(Case when MealType=0 and Kind=1 and clock_id in (select clock_id from clocks where dinroom_id='3') then 1 else 0 end) OneCount3,
from MealRecords M left join (select * from DinLev where isValid=1) DD on M.kind=DD.DinLev_Id
left join employee E on M.emp_id=e.emp_id left join Departs D on M.Depart_id=D.Depart_id
where sign_time>='2015-10-01' and sign_time<='2015-10-19' group by op_ymd, M.depart_id, D.depart_name
这种情况该用 什么方法替换,提示“不能对包含聚合或子查询的表达式执行聚合函数。”