select t1.*,t2.name, (case when t1.status = 'closed' or t1.stage = 'released' then 1 else 0 end) as done, 1 as count from TABLE_STORY as t1 left join TABLE_PRODUCT as t2 on t1.product=t2.id where t1.deleted='0' and t2.deleted='0'