ตรวจสอบ Dxtype





SELECT v.visitdate,v.pid,group_concat(g.diagcode),
max(case when g.dxtype = '01' then g.diagcode else '' end )as '01',
max(case when g.dxtype = '02' then g.diagcode else '' end )as '02',
max(case when g.dxtype = '04' then g.diagcode else '' end )as '04',
max(case when g.dxtype = '05' then g.diagcode else '' end )as '05'
FROM visit v
inner join visitdiag g on v.visitno = g.visitno
where v.visitdate between '2014-10-01' and '2015-09-30'
group by v.visitno
order by v.pid