select count(*) as total_cnt,sum(case when res.exec_status>='1' then 1 else 0 end) as had_exec,sum(case when res.exec_status='0' then 1 else 0 end) as not_exec
select count(*) as total_cnt,sum(case when res.exec_status>='1' then 1 else 0 end) as had_exec,sum(case when res.exec_status='0' then 1 else 0 end) as not_exec
,res.exec_userid,max(res.exec_username) as exec_username
,res.exec_userid,max(res.exec_username) as exec_username
from xm_test_plan_case res where res.plan_id=#{planId}
from xm_test_plan_case res left join xm_test_plan p on res.plan_id=p.id