CREATE OR REPLACE VIEW `ztv_projectsummary` AS select `zt_task`.`project` AS `project`,sum(`zt_task`.`estimate`) AS `estimate`,sum(`zt_task`.`consumed`) AS `consumed`,sum(if(`zt_task`.status != 'cancel' and `zt_task`.status != 'closed', `left`, 0)) AS `left`,count(0) AS `number`,sum(if(((`zt_task`.`status` = 'wait') or (`zt_task`.`status` = 'doing')),1,0)) AS `undone`,sum((`zt_task`.`consumed` + if(`zt_task`.status != 'cancel', `left`, 0))) AS `totalReal` from `zt_task` where ((`zt_task`.`deleted` = '0') and (`zt_task`.`parent` >= '0')) group by `zt_task`.`project`;
