SQL Saved search Different Location: Difference between revisions
Jump to navigation
Jump to search
No edit summary |
No edit summary |
||
| Line 1: | Line 1: | ||
These queries finds records where the assigned locations | These queries finds records where the assigned locations are not the same. They are added to V6.0 as Saved searches with a syntax that works as Saved search <br /> | ||
'''Accident and Victim''' | '''Accident and Victim''' | ||
<pre> | <pre> | ||
Revision as of 08:31, 13 February 2014
These queries finds records where the assigned locations are not the same. They are added to V6.0 as Saved searches with a syntax that works as Saved search
Accident and Victim
SELECT DISTINCT accident_localid FROM accident Inner Join link ON accident.accident_guid = link.from_guid Inner Join victim ON link.to_guid = victim.victim_guid Inner Join location AS AccLoc ON accident.location_guid = AccLoc.location_guid Inner Join location AS VicLoc ON victim.location_guid = VicLoc.location_guid WHERE link.from_link_type = 'Accident' AND (AccLoc.location_guid <> VicLoc.location_guid) ORDER BY accident_localid
Hazard and HazRed
SELECT DISTINCT hazard_localid FROM hazard Inner Join link ON hazard.hazard_guid = link.from_guid Inner Join hazreduc ON link.to_guid = hazreduc.hazreduc_guid Inner Join location AS HazLoc ON hazard.location_guid = HazLoc.location_guid Inner Join location AS HazRedLoc ON hazreduc.location_guid = HazRedLoc.location_guid WHERE link.from_link_type = 'Hazard' AND (HazLoc.location_guid <> HazRedLoc.location_guid) ORDER BY hazard_localid
QM and HazRed
SELECT DISTINCT qa_localid FROM link Inner Join hazreduc ON link.to_guid = hazreduc.hazreduc_guid Inner Join location AS HazLoc Inner Join location AS HazRedLoc ON hazreduc.location_guid = HazRedLoc.location_guid Inner Join qa ON link.from_guid = qa.qa_guid AND HazLoc.location_guid = qa.location_guid WHERE link.from_link_type = 'QA' AND (HazLoc.location_guid <> HazRedLoc.location_guid) ORDER BY qa_localid