ถ้าเขียนสคริปต์รายงานตามด้านล่างใน report designer กรณีที่ไม่มีค่าอยากให้เลขออกมาเป็น 0 แต่ค่าออกมาเป็นค่าว่างทำอย่างไร แต่ถ้า query ปกติในสายฟ้าเลขจะออกมาเป็น 0
set @d1="2008-10-22";
set @d2="2008-11-21";
select a.*,b.IPD,c.OPERATION,d.LR,e.REFEROUT,f.REFERIN
from(select vstdate
,sum(if(main_dep in ("036","006","007","008","009"),1,0)) as "OPD"
,sum(if(main_dep ="011",1,0)) as "ER"
,sum(if(main_dep ="021",1,0)) as "DENT"
,sum(if(main_dep ="023",1,0)) as "SS"
,count(distinct vn) as "TOTALALL"
from ovst
where vstdate between @d1 and @d2
group by vstdate) a
left join
(select dchdate,count(distinct an) as "IPD"
from ipt
where dchdate between @d1 and @d2
group by dchdate) b on b.dchdate=a.vstdate
left join
(select request_operation_date,count(operation_id) as "OPERATION"
from operation_list
where request_operation_date between @d1 and @d2
group by request_operation_date) c on c.request_operation_date=a.vstdate
left join
(select o.vstdate,count(ip.an)+count(o.vn) as "LR"
from ipt_pregnancy ip
left outer join ovst o on o.vstdate=ip.labor_date
where o.vstdate between @d1 and @d2 and o.main_dep="014"
group by o.vstdate) d on d.vstdate=a.vstdate
left join
(select refer_date,count(vn) as "REFEROUT"
from referout
where refer_date between @d1 and @d2
group by refer_date) e on e.refer_date=a.vstdate
left join
(select refer_date,count(vn) as "REFERIN"
from referin
where refer_date between @d1 and @d2
group by refer_date) f on f.refer_date=a.vstdate