Double check a query
I am a bit new to my poisition but for some reason it sometimes take a long time to pull a query from the db. Can I get some if to see if I can optimize my query any more?
SELECT c.udf1_c as "Merial ID", c.udf2_c as "Location ID", c.bus_name as "Practice Name", e.synopsis as " Program Name", d.field4 as "Software", d.field26 as "HSI", d.field27 as "Shared DB",
d.field28 as "Converted Pims", d.field29 as "Open 12 mo. or Less", d2.field1 as "Submission Type", d2.field4 as "Media Issue", c.state as "Clinic's State",
to_char(n.completed_date,'MM/DD/YYYY') as "Assigned Date"
FROM nxscuste c, nxstar_e e, nxsnotes n, nxsdatas d, nxsdatas d2
WHERE e.symptom_code = 'CC'
AND e.completed is null
AND d.type_code = 'ENROLL'
AND n.completed_date in (SELECT MAX(n2.completed_date) from nxsnotes n2 WHERE n2.id = n.id and n2.type = 'DS-BadMedia')
AND d2.type_code = 'RECMEDIA'
AND e.tar_num = d2.id
and e.tar_num = d.id
and e.tar_num = n.id
and c.cust_code = e.cust_code;
Click Here to Expand Forum to Full Width