SQL Saved search Task: Difference between revisions

From IMSMA Wiki
Jump to navigation Jump to search
Created page with "These queries are about Tasks. They are added to V6.0 as Saved searches with a syntax that works as Saved search <br /> '''Hazards not included in any Task''' This query would..."
 
No edit summary
Line 9: Line 9:
hazard_localid
hazard_localid
</pre>
</pre>
 
'''Hazard included in more than one Task''' which could be OK depending on the business rules
 
<pre>
 
SELECT
hazard.hazard_localid,
Count(task_has_objective.task_guid)
FROM
hazard
Inner Join task_has_objective ON hazard.hazard_guid = task_has_objective.hazard_guid
GROUP BY
hazard.hazard_localid
HAVING
Count(task_has_objective.task_guid) >  '1'
ORDER BY
hazard.hazard_localid ASC
</pre>
'''Tasks without Objectives''' which could be OK depending on the business rules
<pre>
SELECT task.localid
FROM task_has_objective
Right Join task ON task.guid = task_has_objective.task_guid
where task_has_objective.task_guid IS NULL
ORDER BY
task.localid
</pre>


[[Category:NoPublic]]
[[Category:NoPublic]]
[[Category:SQL Queries]]
[[Category:SQL Queries]]

Revision as of 08:49, 13 February 2014

These queries are about Tasks. They are added to V6.0 as Saved searches with a syntax that works as Saved search
Hazards not included in any Task This query would need to be adopted together with Ops e.g. all CHA in flat areas should have been tasked

SELECT hazard_localid
FROM hazard 
WHERE hazard.hazard_guid NOT IN 
(SELECT task_has_objective.hazard_guid FROM task_has_objective)
ORDER BY
hazard_localid

Hazard included in more than one Task which could be OK depending on the business rules

SELECT
hazard.hazard_localid,
Count(task_has_objective.task_guid)
FROM
hazard
Inner Join task_has_objective ON hazard.hazard_guid = task_has_objective.hazard_guid
GROUP BY
hazard.hazard_localid
HAVING
Count(task_has_objective.task_guid) >  '1'
ORDER BY
hazard.hazard_localid ASC

Tasks without Objectives which could be OK depending on the business rules

SELECT task.localid
FROM task_has_objective 
Right Join task ON task.guid = task_has_objective.task_guid 
where task_has_objective.task_guid IS NULL
ORDER BY
task.localid