SQL to display inbox mapping
select x.externapp, x.subjectcode, x.subject,
l.resultcode, l.prompt, m.scncode, m.scnvalue, count(*) from inbox x inner join inline l on l.patientid = x.patientid and l.whenreceived = x.whenreceived left join labscreeningmap m on m.facility = x.externapp and m.subjectcode = x.subjectcode and m.resultcode = l.resultcode where x.whenreceived >= "2014-01-01" group by x.externapp, x.subjectcode, x.subject, l.resultcode, l.prompt, m.scncode, m.scnvalue having count(*) > 10 order by 8 desc |