1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31
| SELECT
ATELIER,
RESS,
decode(SEM2,-4,sum(TUTIL)/sum(TOUVMACHINE)*100) as a,
decode(SEM2,-3,sum(TUTIL)/sum(TOUVMACHINE)*100) as b,
decode(SEM2,-2,sum(TUTIL)/sum(TOUVMACHINE)*100) as c,
decode(SEM2,-1,sum(TUTIL)/sum(TOUVMACHINE)*100) as d,
decode(SEM2,0,sum(TUTIL)/sum(TOUVMACHINE)*100) as e
FROM( SELECT
GR_TACHES.LIBELLE as ATELIER,
TACHES.LIBELLE as RESS,
extract(week from HORO_FIN) as SEM,
extract(week from HORO_FIN)-extract(week from current_date)as SEM2,
TRTRAV.TUTIL,
TRTRAV.TOUVMACHINE
FROM
(TACHES INNER JOIN TRTRAV ON TACHES.COD_TACHE = TRTRAV.COD_TACHE) INNER JOIN GR_TACHES ON
TACHES.GR_TACHE = GR_TACHES.GR_TACHE
WHERE
(((GR_TACHES.GR_TACHE)=1 Or (GR_TACHES.GR_TACHE)=2))and
TRTRAV.TOUVMACHINE <>'0'and
TRTRAV.TUTIL <>'0'and
extract(year from HORO_FIN)=extract(year from current_date)and
extract(week from HORO_FIN)> extract(week from current_date)-5
and TACHES.LIBELLE='V20'
)
GROUP BY
ATELIER,
RESS,
SEM2
; |
Partager