select count(
case when (case when status = 1 and complete_time =null then NOW() else complete_time end ) > estimated_finish_time then id else null end
) as overdue,
case
when #{queryDO.period} =0 then DATE_FORMAT(created_time,"%m-%d")
when #{queryDO.period}=1 then WEEK(created_time)
when #{queryDO.period}=2 then DATE_FORMAT(created_time,"%Y-%m")
when #{queryDO.period}=3 then DATE_FORMAT(created_time,"%Y")
end
as date,
count(
case when date_add((case when status = 1 and complete_time = null then NOW() else complete_time end),INTERVAL 1 DAY)
> estimated_finish_time then id else null end
) as goingOverdue,
count( case when status=2 and estimated_finish_time >= complete_time then id else null end ) as periodTotalOnTime,
count(id) as total,
count(case when status=2 then id else null end) as completionTotal,
count(case when status!=2 then id else null end) as uncompletion
case 一定要 使用end 结束 多个when也不需要用逗号隔开