SQL Saved search No links: Difference between revisions
Jump to navigation
Jump to search
No edit summary |
No edit summary |
||
| Line 46: | Line 46: | ||
hazard_localid | hazard_localid | ||
</pre> | </pre> | ||
'''HazRed without link''' If the country records Hazards as outcome of surveys or Clearance/Completion are done on Hazards then there should be links | |||
<pre> | |||
SELECT DISTINCT | |||
hazreduc_localid | |||
FROM | |||
link | |||
Right Join hazreduc ON link.from_guid = hazreduc.hazreduc_guid | |||
WHERE | |||
link.from_guid IS NULL | |||
ORDER BY | |||
hazreduc_localid | |||
</pre> | |||
'''QM without link''' QMs really should have links to other objects | |||
<pre> | |||
SELECT DISTINCT | |||
qa_localid | |||
FROM | |||
qa | |||
Left Join link ON qa.qa_guid = link.from_guid | |||
WHERE | |||
link.from_guid IS NULL | |||
ORDER BY | |||
qa_localid | |||
</pre> | |||
[[Category:NoPublic]] | [[Category:NoPublic]] | ||
[[Category:SQL Queries]] | [[Category:SQL Queries]] | ||
Revision as of 08:19, 13 February 2014
These queries finds records that do not have links which might not be a data quality issue depending on the business rules in your country. They are added to V6.0 as Saved searches with a syntax that works as Saved search
Accidents without link to Victim
SELECT DISTINCT accident_localid FROM accident WHERE accident.accident_guid NOT IN ( SELECT DISTINCT accident.accident_guid FROM link Inner Join accident ON accident.accident_guid = link.from_guid WHERE link.to_link_type = 'Victim') ORDER BY accident_localid
Victims without link to Accident
SELECT DISTINCT victim_localid FROM victim WHERE victim.victim_guid NOT IN ( SELECT DISTINCT victim.victim_guid FROM link Inner Join victim ON victim.victim_guid = link.from_guid WHERE link.to_link_type = 'Accident') ORDER BY victim_localid
Hazards without links This query needs to be adopted to the business rules of the country e.g. all Closed or all CHA should have links
SELECT DISTINCT hazard_localid FROM hazard Left Join link ON hazard.hazard_guid = link.from_guid WHERE link.from_guid IS NULL ORDER BY hazard_localid
HazRed without link If the country records Hazards as outcome of surveys or Clearance/Completion are done on Hazards then there should be links
SELECT DISTINCT hazreduc_localid FROM link Right Join hazreduc ON link.from_guid = hazreduc.hazreduc_guid WHERE link.from_guid IS NULL ORDER BY hazreduc_localid
QM without link QMs really should have links to other objects
SELECT DISTINCT qa_localid FROM qa Left Join link ON qa.qa_guid = link.from_guid WHERE link.from_guid IS NULL ORDER BY qa_localid