select t.typename as name
  ,count(*) as c
  ,sum(if(task.planendtime<now() +INTERVAL 1 day && task.planendtime>now(),1,0)) as c1
  ,sum(if(task.planendtime<now(),1,0)) as c2
from p_projecttask task
left  join t_s_typegroup tg  on tg.typegroupcode='tasktype'
left join t_s_type t on t.typegroupid=tg.id and t.typecode=task.tasktype
where task.taskstatus=0 and task.owner=:userId
group by tasktype