SQL Saved search Different Location: Difference between revisions
Jump to navigation
Jump to search
Created page with "These queries finds records where the assigned locations is not the same. They are added to V6.0 as Saved searches with a syntax that works as Saved search <br /> '''Accident ..." |
No edit summary |
||
| Line 2: | Line 2: | ||
'''Accident and Victim''' | '''Accident and Victim''' | ||
<pre> | <pre> | ||
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 | |||
</pre> | </pre> | ||
'''Hazard and HazRed''' | '''Hazard and HazRed''' | ||
| Line 20: | Line 32: | ||
hazard_localid | hazard_localid | ||
</pre> | </pre> | ||
'''QM and HazRed''' | |||
<pre> | |||
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 | |||
</pre> | |||
[[Category:NoPublic]] | [[Category:NoPublic]] | ||
[[Category:SQL Queries]] | [[Category:SQL Queries]] | ||
Revision as of 08:30, 13 February 2014
These queries finds records where the assigned locations is 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