แบบนี้มั้ยครับ
select a.vstdate
,(select count(*) from er_regist where vstdate=a.vstdate and er_period="1") 'เช้า'
,(select count(*) from er_regist where vstdate=a.vstdate and er_period="2") 'บ่าย'
,(select count(*) from er_regist where vstdate=a.vstdate and er_period="3") 'ดึก'
,(select count(*) from er_regist where vstdate=a.vstdate) 'รวม'
from (select vstdate
from vn_stat
where vstdate between '2014-04-01' and '2014-04-30'
group by vstdate) a