select t1.id,t4.name as project,t4.id,IF(t4.multiple="1",t1.name,"") as execution,t1.status,t2.number as tasks,round(t2.consumed,2) as consumed,round(t2.`left`,2) as `left`,t3.stories,t2.undone as undoneTask,t3.undone as undoneStory,t2.totalReal from TABLE_EXECUTION as t1 
left join ztv_executionsummary as t2 on t1.id=t2.execution
left join ztv_projectstories as t3 on t1.id=t3.execution
left join TABLE_PROJECT as t4 on t4.id=t1.project
where t1.deleted='0' and t1.type in ('sprint','stage') and if($project='',1,t4.id=$project) and if($execution='',1,t1.id=$execution) and if($status='',1,t1.status=$status)