1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17
| SELECT cast(cast(Nbre_actions_préventives as float) / cast(Nbre_actions_améliorations as float) AS decimal (10,3)) as 'Pourcentage_action_préventives', A.Mois, A.Année
FROM
(
SELECT Count(T_Action_Amelioration.AMLngId) as 'Nbre_actions_améliorations', datename(m,T_Action_Amelioration.AMDateCreation) AS 'Mois', Year(T_Action_Amelioration.AMDateCreation) AS 'Année'
FROM dbo.T_Action_Amelioration T_Action_Amelioration
WHERE (Year(T_Action_Amelioration.AMDateCreation) >= '2012')
GROUP BY datename(m,T_Action_Amelioration.AMDateCreation), Year(T_Action_Amelioration.AMDateCreation)
) A
join(
SELECT Count(T_Action_Amelioration.AMLngId) as 'Nbre_actions_préventives', datename(m,T_Action_Amelioration.AMDateCreation) AS 'Mois', Year(T_Action_Amelioration.AMDateCreation) AS 'Année'
FROM dbo.T_Action_Amelioration T_Action_Amelioration
WHERE (Year (T_Action_Amelioration.AMDateCreation) >='2012') AND (T_Action_Amelioration.AMLngTypeId=0)
GROUP BY datename(m,T_Action_Amelioration.AMDateCreation), Year(T_Action_Amelioration.AMDateCreation)
) B
on A.Année=B.Année and A.Mois=B.Mois
GROUP BY A.Mois, A.Année,Nbre_actions_améliorations, Nbre_actions_préventives; |
Partager