ประมาณนี้เปล่าครับ...
" select ast.an,ast.pdx,ip.dx0,ip.dx1,ip.dx2,ip.dx3,ip.dx4,ip.dx5,i.name,ip.drg,ip.rw,ip.mdc,
ip.wtlos,ip.ot,ip.adjrw,ip.splty from ipt ip
left outer join referout r on r.vn=ip.an
left outer join an_stat ast on ast.an=r.vn
left outer join icd101 i on i.code=ast.pdx
where ast.pdx <>"" and ast.dchdate between'2011-06-01'and'2011-06-30'
group by ast.pdx
order by ip.rw desc "
(ตัวอย่างนะครับ..)