select t1.id,t5.name as project,IF(t5.multiple="1",t1.name,"") as execution,CONCAT(t1.begin,' ~ ',t1.end) as timeLimit,t2.teams,t3.stories,round(t4.consumed,1) as consumed,t4.number, t1.status as projectstatus 
from TABLE_EXECUTION as t1
 left join ztv_projectteams as t2 on t1.id=t2.execution
left join ztv_projectstories as t3 on t1.id=t3.execution
 left join ztv_executionsummary as t4 on t1.id=t4.execution 
left join TABLE_PROJECT as t5 on t1.project=t5.id 
where t1.deleted='0' and t1.type in ('sprint','stage') and if($project='',1,t5.id=$project) and if($status='',1,t1.status=$status) and if($beginDate='',1,t1.begin>=$beginDate) and if($endDate='',1,t1.end<=$endDate)