Commit f6ee5b33 authored by Antony Le Courtes's avatar Antony Le Courtes
Browse files

Modification des V_CONTRAT_SERVICES.sql et V_CONTRAT_MAIN.sql pour ventiler...

Modification des V_CONTRAT_SERVICES.sql et V_CONTRAT_MAIN.sql pour ventiler les heures par types d'intervention
parent bac47fc6
Loading
Loading
Loading
Loading
+1 −1
Changes for data/ddl/view/V_CONTRAT_MAIN.sql: 1 added line, 1 removed line.
Original line number Diff line number Diff line
CREATE OR REPLACE FORCE VIEW V_CONTRAT_MAIN AS
WITH hs AS (
  SELECT contrat_id, sum(heures) "serviceTotal", listagg(libelleAutres, ', ') WITHIN GROUP (ORDER BY libelleAutres) "libelleAutres" FROM V_CONTRAT_SERVICES GROUP BY contrat_id
  SELECT contrat_id, sum(heures) "serviceTotal", max(libelleAutres) "libelleAutres" FROM V_CONTRAT_SERVICES GROUP BY contrat_id
)
SELECT
  ct.annee_id,
+10 −3
Changes for data/ddl/view/V_CONTRAT_SERVICES.sql: 10 added lines, 3 removed lines.
Original line number Diff line number Diff line
@@ -22,15 +22,21 @@ WITH services AS (

)  ,
servicesAutres AS (
	SELECT
		t.contrat_id                  																	   contrat_id,
		listagg(t.type_intervention_libelle, ', ') WITHIN GROUP (ORDER BY t.type_intervention_libelle)	   type_intervention_libelle
		FROM (
			SELECT DISTINCT
			  c.id                                             						contrat_id,
	  ti.libelle                                                            type_intervenation_libelle
			  ti.libelle                                                            type_intervention_libelle
			FROM
			            contrat                  c
			       JOIN volume_horaire          vh ON vh.contrat_id = c.id AND vh.histo_destruction IS NULL
			       JOIN type_intervention       ti ON ti.id = vh.type_intervention_id
			WHERE ti.code NOT IN ('CM','TD','TP')
	GROUP BY c.id
		) t
		GROUP by
		t.contrat_id


)
@@ -46,7 +52,7 @@ SELECT
  CASE WHEN sum(s.heures_autres) = 0 THEN to_char(0) ELSE replace(ltrim(to_char(sum(s.heures_autres), '999999.00')),'.',',') END "autres",
  SUM(heures_totales)																			                                 heures,
  SUM(heures_totales) 																									 		 "serviceHeures",
  LISTAGG(sa.type_intervention_libelle, ', ') WITHIN GROUP (ORDER BY sa.type_intervention_libelle)									 "libelleAutres"
  MAX(sa.type_intervention_libelle)																								 "libelleAutres"
  FROM services s
  LEFT JOIN servicesAutres sa ON sa.contrat_id = s.contrat_id
  GROUP BY
@@ -54,3 +60,4 @@ SELECT
  s."serviceComposante",
  s."serviceCode",
  s."serviceLibelle"