Before you run the whole thing, can you run the following query:
;with pc_c as (
select cytology_id , refer_doctor
from lis.pathcase pc inner join lis.cytology c On pc.cytology_id = c.id
WHERE pc.sign_out = 1
and pc.report_processed >= '2014-01-01'
and pc.report_processed <= '2015-01-01')
,docbet as ( Select bet.id as betid, doc.first_name, doc.surname, doc.id as docid, bet.name
from lis.bethesta bet, doctor as doc)
Select * from docbet Left JOIN pc_c On pc_c.refer_doctor = docbet.docid and pc_c.besthesda_id = docbet.betid
No comments:
Post a Comment