select 'Intime' as type
,count(if((h.holiday_date is null or o.visit_type='I'),o.hn,null)) 'case53'
,count(distinct if((h.holiday_date is null or o.visit_type='I'),o.hn,null)) 'visit53'
from ovst o
left join holiday h on h.holiday_date=o.vstdate
where o.vstdate between '2009-10-1' and '2010-9-30'
union
select 'OutTime' as type
,count(if(not (h.holiday_date is null or o.visit_type='I'),o.hn,null)) 'case53'
,count(distinct if(not (h.holiday_date is null or o.visit_type='I'),o.hn,null)) 'visit53'
from ovst o
left join holiday h on h.holiday_date=o.vstdate
where o.vstdate between '2009-10-1' and '2010-9-30'
union
select 'Total' as type
,count(o.hn) 'case53'
,count(distinct o.hn) 'visit53'
from ovst o
left join holiday h on h.holiday_date=o.vstdate
where o.vstdate between '2009-10-1' and '2010-9-30'