First off I'm still a bit new to the creation of queries so go easy on me! I'm working on checking transactions and whether they're "inbound", "outbound", or "other". As it stands, I'm able to collect the inbound and outbound information fine (although I'm not sure it's the most efficient query but we'll save that for another day) but am struggling when it comes to finding out the best method of acquiring the "other". I have "facility_id" on the clinic table (which is my outbound) and then "facility_id" on the facility table (which is my inbound). However, I have "facilityid" on my auditentry table which contains the facility_id's from both the clinic and facility table as well as some extra. I'm looking to grab those extra values that aren't in the other two tables. Would this require a couple queries to pull that information from those two tables and then comparing it? Any guidance would be appreciated!select 'OUTBOUND' as direction, clinic.facility_id, Count(auditentry.controlid), ' ' As "Direction", 'April' AS "Month", ' ' AS Mnemonic from auditentry right outer join clinic on (auditentry.facilityid = clinic.facility_id) and(timestamp between '2011-04-01' and '2011-04-30') and (auditentry.status != 0) and (auditentry.FacilityName Is Not NULL) group by clinic.facility_idunionselect 'INBOUND' as direction, facility.facility_id, Count(auditentry.controlid), ' ' As "Direction", 'April' AS "Month", ' ' AS Mnemonic from auditentry right outer join facility on (auditentry.facilityid = facility.facility_id) and(timestamp between '2011-04-01' and '2011-04-30') and (auditentry.status != 0) and (auditentry.FacilityName Is Not NULL) group by facility.facility_id;
For what it's worth, here's what I have so far on the third query. select 'OTHER' as direction, auditentry.facilityid, count(auditentry.controlid), 'April' AS "Month" from auditentry left outer join facility on (auditentry.facilityid = facility.facility_id) and (auditentry.facilityid != facility.facility_id) and(timestamp between '2011-04-01' and '2011-04-30') and (auditentry.status != 0) and (auditentry.FacilityName Is Not NULL) group by auditentry.facilityid;