select x.xn,xrf.film_id,xf.film_name,x.hn,x.request_date,x.request_time,x.report_date,
x.report_time,x.doctor,x.xray_type,
concat(p.pname,' ',p.fname,' ',p.lname) as ptname ,
d.name as doctor_name , d2.name as request_doctor_name ,
t.name as xray_type_name ,x.vn,x.an , xi.xray_items_name,
v.pttype,ptt.name as pttname,v.pcode,xh.pt_xn,x.staff,xrf.price,v.age_y,xh.department_name
from xray_report x
left outer join xray_head xh on xh.vn=x.vn
left outer join patient p on p.hn=x.hn
left outer join vn_stat v on v.vn = x.vn
left outer join doctor d on d.code=x.doctor
left outer join doctor d2 on d2.code=x.request_doctor
left outer join xray_type t on t.xray_type = x.xray_type
left outer join xray_items xi on xi.xray_items_code=x.xray_items_code
left outer join xray_report_film xrf on xrf.xn = x.xn
left outer join xray_film xf on xf.film_id = xrf.film_id
left outer join pttype ptt on ptt.pttype = v.pttype
where (x.request_date between '2010-01-01' and '2010-01-12') and x.xray_items_code not in (0)
order by x.request_date,x.request_time,x.hn