From b6245a32ae9b798290d594475699cf8e334d048c Mon Sep 17 00:00:00 2001 From: Jean-Baptiste Nez Date: Mon, 2 Dec 2024 01:09:11 +0000 Subject: [PATCH] big work --- dbt_project.yml | 7 ++ .../capacite/int_capacite_etablissement.sql | 25 +++++ .../int_capacite_etablissement_join.sql | 51 +++++++++ models/capacite/int_capacite_service.sql | 63 +++++++++++ models/capacite_agg/mart_capacite_dpt_reg.sql | 103 ++++++++++++++++++ .../mart_capacite_dpt_reg_evol.sql | 69 ++++++++++++ .../class_join_total_morbidite.sql | 3 +- .../class_join_total_morbidite_population.sql | 46 ++++---- .../class_join_total_morbidite_capacite.sql | 26 ++++- models/schema.yml | 12 ++ ...services_h__capacite_2021_service_stjr.sql | 34 ++++++ ...es_h__capacite_2022_etablissement_stjr.sql | 41 +++++++ ...ces_h__capacite_2022_par_etablissement.sql | 39 +++++++ ...services_h__capacite_2022_par_services.sql | 42 +++++++ 14 files changed, 533 insertions(+), 28 deletions(-) create mode 100644 models/capacite/int_capacite_etablissement.sql create mode 100644 models/capacite/int_capacite_etablissement_join.sql create mode 100644 models/capacite/int_capacite_service.sql create mode 100644 models/capacite_agg/mart_capacite_dpt_reg.sql create mode 100644 models/capacite_agg/mart_capacite_dpt_reg_evol.sql create mode 100644 models/staging/capacite_services_h/stg_capacite_services_h__capacite_2021_service_stjr.sql create mode 100644 models/staging/capacite_services_h/stg_capacite_services_h__capacite_2022_etablissement_stjr.sql create mode 100644 models/staging/capacite_services_h/stg_capacite_services_h__capacite_2022_par_etablissement.sql create mode 100644 models/staging/capacite_services_h/stg_capacite_services_h__capacite_2022_par_services.sql diff --git a/dbt_project.yml b/dbt_project.yml index 00009c7..91dc074 100644 --- a/dbt_project.yml +++ b/dbt_project.yml @@ -87,4 +87,11 @@ models: +materialized: table join_total_morbidite_capacite: +schema: join_total_morbidite_capacite + +materialized: table + + capacite: + +schema: capacite + +materialized: view + capacite_agg: + +schema: capacite_agg +materialized: table \ No newline at end of file diff --git a/models/capacite/int_capacite_etablissement.sql b/models/capacite/int_capacite_etablissement.sql new file mode 100644 index 0000000..57b613f --- /dev/null +++ b/models/capacite/int_capacite_etablissement.sql @@ -0,0 +1,25 @@ +SELECT +fi as id_etablissement, +an as annee, +rs as nom_etablissement, +stj as statut_juridique, +cat as categ_etablissement, +dep as departement, +SPLIT(dep, " - ")[SAFE_OFFSET(0)] AS code_departement, +SPLIT(dep, " - ")[SAFE_OFFSET(1)] AS nom_departement, +reg as region, +SPLIT(reg, " - ")[SAFE_OFFSET(0)] AS code_region, +SPLIT(reg, " - ")[SAFE_OFFSET(1)] AS nom_region, +espic as code_espic, +LIT as lit_hospi_complete, +SEJHC as sejour_hospi_complete, +JOU as journee_hospi_complete, +PLA as place_hospi_partielle, +SEJHP as sejour_hospi_partielle, +PAS as passage_urgence, +SEJACC as sejour_accouchement, +SEHEM as seance_hemodyalise, +SERAD as seance_radiotherapie, +SECHI as seance_chimio, + FROM {{ref("stg_capacite_services_h__capacite_2022_par_etablissement")}} +WHERE an >= 2018 \ No newline at end of file diff --git a/models/capacite/int_capacite_etablissement_join.sql b/models/capacite/int_capacite_etablissement_join.sql new file mode 100644 index 0000000..7aa0fa5 --- /dev/null +++ b/models/capacite/int_capacite_etablissement_join.sql @@ -0,0 +1,51 @@ +With join_capacite as ( + SELECT + t2.id_etablissement, + t2.annee as annee, + DATE(CAST(t2.annee AS STRING) || "-12-31") as year, + t2.service_medical, + t1.nom_etablissement AS nom_etablissement, + t1.statut_juridique AS statut_juridique, + t1.categ_etablissement AS categ_etablissement, + t1.departement AS departement, + t1.code_departement AS code_departement, + t1.nom_departement AS nom_departement, + t1.region AS region, + t1.code_region AS code_region, + t1.nom_region AS nom_region, + t1.code_espic AS code_espic, + t2.lit_hospi_complete AS lit_hospi_complete_detail, + t2.sejour_hospi_complete AS sejour_hospi_complete_detail, + t2.journee_hospi_complete AS journee_hospi_complete_detail, + t2.place_hospi_partielle AS place_hospi_partielle_detail, + t2.sejour_hospi_partielle AS sejour_hospi_partielle_detail, + t2.passage_urgence AS passage_urgence_detail, + t2.sejour_accouchement AS sejour_accouchement_detail, + t2.seance_hemodyalise AS seance_hemodyalise_detail, + t2.seance_radiotherapie AS seance_radiotherapie_detail, + t2.seance_chimio AS seance_chimio_detail, + t1.lit_hospi_complete AS total_lit_hospi_complete, + t1.sejour_hospi_complete AS total_sejour_hospi_complete, + t1.journee_hospi_complete AS total_journee_hospi_complete, + t1.place_hospi_partielle AS total_place_hospi_partielle, + t1.sejour_hospi_partielle AS total_sejour_hospi_partielle, +FROM + {{ref("int_capacite_etablissement")}} AS t1 +JOIN + {{ref("int_capacite_service")}} AS t2 +ON + t1.id_etablissement = t2.id_etablissement + AND t1.annee = t2.annee +) + +SELECT *, + CASE + WHEN service_medical = 'Soins de suite et réadaptation' THEN 'SSR' + WHEN service_medical = 'Gynéco-Obstétrique' THEN 'O' + WHEN service_medical = 'Médecine' THEN 'M' + WHEN service_medical = 'Chirurgie' THEN 'C' + WHEN service_medical = 'Soins de longue durée' THEN 'ESND' + WHEN service_medical = 'Psychiatrie' THEN 'PSY' + WHEN service_medical = 'Hospitalisation à domicile' THEN NULL +END AS service_classification , +FROM `join_capacite` diff --git a/models/capacite/int_capacite_service.sql b/models/capacite/int_capacite_service.sql new file mode 100644 index 0000000..4fcf46e --- /dev/null +++ b/models/capacite/int_capacite_service.sql @@ -0,0 +1,63 @@ +-- With stjr1 as ( +-- SELECT +-- t1.*, +-- t2.stjr +-- FROM {{ref('stg_capacite_services_h__capacite_2022_par_services')}} t1 +-- LEFT JOIN ( +-- SELECT DISTINCT FI, AN, stjr +-- FROM {{ref('stg_capacite_services_h__capacite_2021_service_stjr')}} +-- WHERE AN = 2021 +-- ) t2 +-- ON t1.fi = t2.FI +-- WHERE t1.an >= 2018 AND t1.an < 2022 +-- ), +-- stjr2 as ( +-- SELECT +-- t1.*, +-- t2.stjr +-- FROM {{ref('stg_capacite_services_h__capacite_2022_par_services')}} t1 +-- LEFT JOIN ( +-- SELECT DISTINCT fi, an, stjr +-- FROM {{ref('stg_capacite_services_h__capacite_2022_etablissement_stjr')}} +-- WHERE AN = 2022 +-- ) t2 +-- ON CAST(t1.fi AS STRING) = t2.fi +-- WHERE t1.an = 2022 +-- ), +-- join_stjr as ( +-- SELECT * +-- FROM stjr1 +-- UNION ALL +-- SELECT * +-- FROM stjr2 +-- ) + +SELECT +fi as id_etablissement, +an as annee, +rs as nom_etablissement, +stj as statut_juridique, +cat as categ_etablissement, +dep as departement, +SPLIT(dep, " - ")[SAFE_OFFSET(0)] AS code_departement, +SPLIT(dep, " - ")[SAFE_OFFSET(1)] AS nom_departement, +reg as region, +SPLIT(reg, " - ")[SAFE_OFFSET(0)] AS code_region, +SPLIT(reg, " - ")[SAFE_OFFSET(1)] AS nom_region, +-- stjr as statut_entite, +espic as code_espic, +DISCI as discipline_equipement, +DISCIPLINE as service_medical, +LIT as lit_hospi_complete, +SEJHC as sejour_hospi_complete, +JOU as journee_hospi_complete, +PLA as place_hospi_partielle, +SEJHP as sejour_hospi_partielle, +PAS as passage_urgence, +SEJACC as sejour_accouchement, +SEHEM as seance_hemodyalise, +SERAD as seance_radiotherapie, +SECHI as seance_chimio, +cle_unique +FROM {{ref('stg_capacite_services_h__capacite_2022_par_services')}} +WHERE an >= 2018 \ No newline at end of file diff --git a/models/capacite_agg/mart_capacite_dpt_reg.sql b/models/capacite_agg/mart_capacite_dpt_reg.sql new file mode 100644 index 0000000..5345ead --- /dev/null +++ b/models/capacite_agg/mart_capacite_dpt_reg.sql @@ -0,0 +1,103 @@ +WITH dpt as ( + SELECT + id_etablissement, + annee, + year, + service_medical, + service_classification, + nom_etablissement, + statut_juridique, + categ_etablissement, + departement as region, + code_departement as code_region, + nom_departement as nom_region, + code_espic, + lit_hospi_complete_detail, + sejour_hospi_complete_detail, + journee_hospi_complete_detail, + place_hospi_partielle_detail, + sejour_hospi_partielle_detail, + passage_urgence_detail, + sejour_accouchement_detail, + seance_hemodyalise_detail, + seance_radiotherapie_detail, + seance_chimio_detail, + total_lit_hospi_complete, + total_sejour_hospi_complete, + total_journee_hospi_complete, + total_place_hospi_partielle, + total_sejour_hospi_partielle, + FROM {{ref("int_capacite_etablissement_join")}} +), +reg as ( + SELECT + id_etablissement, + annee, + year, + service_medical, + service_classification, + nom_etablissement, + statut_juridique, + categ_etablissement, + region, + code_region, + nom_region, + code_espic, + lit_hospi_complete_detail, + sejour_hospi_complete_detail, + journee_hospi_complete_detail, + place_hospi_partielle_detail, + sejour_hospi_partielle_detail, + passage_urgence_detail, + sejour_accouchement_detail, + seance_hemodyalise_detail, + seance_radiotherapie_detail, + seance_chimio_detail, + total_lit_hospi_complete, + total_sejour_hospi_complete, + total_journee_hospi_complete, + total_place_hospi_partielle, + total_sejour_hospi_partielle, + FROM {{ref("int_capacite_etablissement_join")}} +), +union1 as ( +SELECT * +FROM dpt +UNION ALL +SELECT * +FROM reg +) + +SELECT + annee, + year, + region, + code_region, + nom_region, + service_medical, + service_classification, + SUM(lit_hospi_complete_detail) as lit_hospi_complete, + SUM(sejour_hospi_complete_detail) as sejour_hospi_complete, + SUM(journee_hospi_complete_detail) as journee_hospi_complete, + SUM(place_hospi_partielle_detail) as place_hospi_partielle, + SUM(sejour_hospi_partielle_detail) as sejour_hospi_partielle, + SUM(passage_urgence_detail) as passage_urgence, + SUM(sejour_accouchement_detail) as sejour_accouchement, + SUM(seance_hemodyalise_detail) as seance_hemodyalise, + SUM(seance_radiotherapie_detail) as seance_radiotherapie, + SUM(seance_chimio_detail) as seance_chimio, +FROM union1 +GROUP BY + annee, + year, + region, + code_region, + nom_region, + service_medical, + service_classification + + + + + + diff --git a/models/capacite_agg/mart_capacite_dpt_reg_evol.sql b/models/capacite_agg/mart_capacite_dpt_reg_evol.sql new file mode 100644 index 0000000..ab29ede --- /dev/null +++ b/models/capacite_agg/mart_capacite_dpt_reg_evol.sql @@ -0,0 +1,69 @@ + WITH base_data AS ( + SELECT + annee, + year, + region, + code_region, + nom_region, + service_medical, + service_classification, + lit_hospi_complete, + sejour_hospi_complete, + journee_hospi_complete, + place_hospi_partielle, + sejour_hospi_partielle, + passage_urgence + ,AVG(lit_hospi_complete) OVER (PARTITION BY annee, region, code_region, nom_region, service_medical, service_classification) AS lit_hospi_complete1 + ,AVG(sejour_hospi_complete) OVER (PARTITION BY annee, region, code_region, nom_region, service_medical, service_classification) AS sejour_hospi_complete1 + ,AVG(journee_hospi_complete) OVER (PARTITION BY annee, region, code_region, nom_region, service_medical, service_classification) AS journee_hospi_complete1 + ,AVG(place_hospi_partielle) OVER (PARTITION BY annee, region, code_region, nom_region, service_medical, service_classification) AS place_hospi_partielle1 + ,AVG(sejour_hospi_partielle) OVER (PARTITION BY annee, region, code_region, nom_region, service_medical, service_classification) AS sejour_hospi_partielle1 + ,AVG(passage_urgence) OVER (PARTITION BY annee, region, code_region, nom_region, service_medical, service_classification) AS passage_urgence1 + FROM {{ref("mart_capacite_dpt_reg")}} +), +evolution_data AS ( + SELECT + bd1.*, + round(bd1.lit_hospi_complete1 - COALESCE(bd2.lit_hospi_complete1, 0),2) AS evolution_lit_hospi_complete1, + CASE + WHEN COALESCE(bd2.lit_hospi_complete1, 0) = 0 THEN NULL + ELSE Round(safe_divide((bd1.lit_hospi_complete1 - bd2.lit_hospi_complete1) , bd2.lit_hospi_complete1), 2) + END AS evolution_percent_lit_hospi_complete1, + round(bd1.sejour_hospi_complete1 - COALESCE(bd2.sejour_hospi_complete1, 0),2) AS evolution_sejour_hospi_complete1, + CASE + WHEN COALESCE(bd2.sejour_hospi_complete1, 0) = 0 THEN NULL + ELSE Round(safe_divide((bd1.sejour_hospi_complete1 - bd2.sejour_hospi_complete1) , bd2.sejour_hospi_complete1), 2) + END AS evolution_percent_sejour_hospi_complete1, + round(bd1.journee_hospi_complete1 - COALESCE(bd2.journee_hospi_complete1, 0),2) AS evolution_journee_hospi_complete1, + CASE + WHEN COALESCE(bd2.journee_hospi_complete1, 0) = 0 THEN NULL + ELSE Round(safe_divide((bd1.journee_hospi_complete1 - bd2.journee_hospi_complete1) , bd2.journee_hospi_complete1), 2) + END AS evolution_percent_journee_hospi_complete1, + round(bd1.place_hospi_partielle1 - COALESCE(bd2.place_hospi_partielle1, 0),2) AS evolution_place_hospi_partielle1, + CASE + WHEN COALESCE(bd2.place_hospi_partielle1, 0) = 0 THEN NULL + ELSE Round(safe_divide((bd1.place_hospi_partielle1 - bd2.place_hospi_partielle1) , bd2.place_hospi_partielle1), 2) + END AS evolution_percent_place_hospi_partielle1, + round(bd1.sejour_hospi_partielle1 - COALESCE(bd2.sejour_hospi_partielle1, 0),2) AS evolution_sejour_hospi_partielle1, + CASE + WHEN COALESCE(bd2.sejour_hospi_partielle1, 0) = 0 THEN NULL + ELSE Round(safe_divide((bd1.sejour_hospi_partielle1 - bd2.sejour_hospi_partielle1) , bd2.sejour_hospi_partielle1), 2) + END AS evolution_percent_sejour_hospi_partielle1, + round(bd1.passage_urgence1 - COALESCE(bd2.passage_urgence1, 0),2) AS evolution_passage_urgence1, + CASE + WHEN COALESCE(bd2.passage_urgence1, 0) = 0 THEN NULL + ELSE Round(safe_divide((bd1.passage_urgence1 - bd2.passage_urgence1) , bd2.passage_urgence1), 2) + END AS evolution_percent_passage_urgence1 + FROM base_data bd1 + LEFT JOIN base_data bd2 + ON bd1.region = bd2.region + AND bd1.code_region = bd2.code_region + AND bd1.nom_region = bd2.nom_region + AND bd1.service_medical = bd2.service_medical + AND bd1.service_classification = bd2.service_classification + AND bd1.annee = bd2.annee + 1 +) +SELECT *, + CONCAT(region , "_" , annee , "_" , service_classification) as cle_unique +FROM evolution_data +ORDER BY region, annee \ No newline at end of file diff --git a/models/join_total_morbidite/class_join_total_morbidite.sql b/models/join_total_morbidite/class_join_total_morbidite.sql index 63de89e..3ded8b4 100644 --- a/models/join_total_morbidite/class_join_total_morbidite.sql +++ b/models/join_total_morbidite/class_join_total_morbidite.sql @@ -73,6 +73,7 @@ WITH mega_join AS ( ON t1.cle_unique = t3.cle_unique WHERE t1.sexe = 'Ensemble' AND t3.sexe = 'Ensemble' + AND t1.tranche_age = 'Tous âges confondus' ) @@ -82,4 +83,4 @@ SELECT FROM mega_join AS t1 LEFT JOIN {{ref("stg_morbidite_h__class_services")}} c2 ON t1.nom_pathologie = c2.pathologie - +ORDER BY cle_unique diff --git a/models/join_total_morbidite/class_join_total_morbidite_population.sql b/models/join_total_morbidite/class_join_total_morbidite_population.sql index 4ee163e..6542270 100644 --- a/models/join_total_morbidite/class_join_total_morbidite_population.sql +++ b/models/join_total_morbidite/class_join_total_morbidite_population.sql @@ -1,23 +1,27 @@ -WITH population as ( +WITH +join_dpt AS ( SELECT - CAST(code_departement as INT64) as code_region - ,nom_departement as region - ,CONCAT(code_departement ," - ", nom_departement) as cle_region - ,annee - ,population - FROM {{ref("stg_pop_departement__population_departement")}} - UNION ALL + t1.*, + t2.population AS population + FROM {{ ref("class_join_total_morbidite") }} t1 + LEFT JOIN {{ ref("stg_pop_departement__population_departement") }} t2 + ON t1.annee = t2.annee + AND t1.nom_region = t2.nom_departement + WHERE t1.niveau = 'Départements' +), +join_reg AS ( SELECT - code_region - ,region - ,CONCAT(code_region ," - ", region) as cle_region - ,annee - ,population - FROM {{ref("stg_pop_departement__population_region")}} -) - SELECT - t1.* - ,t2.population -FROM {{ref("class_join_total_morbidite")}} t1 -LEFT JOIN population as t2 -ON t1.annee = t2.annee AND t1.region = t2.cle_region + t1.*, + t2.population AS population + FROM {{ ref("class_join_total_morbidite") }} t1 + LEFT JOIN {{ ref("stg_pop_departement__population_region") }} t2 + ON t1.annee = t2.annee + AND t1.nom_region = t2.region + WHERE t1.niveau = 'Régions' +) + +SELECT * +FROM join_dpt +UNION ALL +SELECT * +FROM join_reg \ No newline at end of file diff --git a/models/join_total_morbidite_capacite/class_join_total_morbidite_capacite.sql b/models/join_total_morbidite_capacite/class_join_total_morbidite_capacite.sql index 7707c62..8a845b8 100644 --- a/models/join_total_morbidite_capacite/class_join_total_morbidite_capacite.sql +++ b/models/join_total_morbidite_capacite/class_join_total_morbidite_capacite.sql @@ -74,12 +74,26 @@ WITH agg_class as( SELECT t1.* - ,t2.total_lit_hospi_complete - ,t2.total_sejour_hospi_complete - ,t2.total_journee_hospi_complete - ,t2.total_place_hospi_partielle - ,t2.total_sejour_hospi_partielle + ,t2.lit_hospi_complete + ,t2.sejour_hospi_complete + ,t2.journee_hospi_complete + ,t2.place_hospi_partielle + ,t2.sejour_hospi_partielle + ,t2.passage_urgence + ,t2.evolution_lit_hospi_complete1 as evolution_lit_hospi_complete + ,t2.evolution_percent_lit_hospi_complete1 as evolution_percent_lit_hospi_complete + ,t2.evolution_sejour_hospi_complete1 as evolution_sejour_hospi_complete + ,t2.evolution_percent_sejour_hospi_complete1 as evolution_percent_sejour_hospi_complete + ,t2.evolution_journee_hospi_complete1 as evolution_journee_hospi_complete + ,t2.evolution_percent_journee_hospi_complete1 as evolution_percent_journee_hospi_complete + ,t2.evolution_place_hospi_partielle1 as evolution_place_hospi_partielle + ,t2.evolution_percent_place_hospi_partielle1 as evolution_percent_place_hospi_partielle + ,t2.evolution_sejour_hospi_partielle1 as evolution_sejour_hospi_partielle + ,t2.evolution_percent_sejour_hospi_partielle1 as evolution_percent_sejour_hospi_partielle + ,t2.evolution_passage_urgence1 as evolution_passage_urgence + ,t2.evolution_percent_passage_urgence1 as evolution_percent_passage_urgence FROM agg_class t1 -LEFT JOIN {{ref("stg_capacite_services_h__capacite_services_dpt_region")}} t2 +LEFT JOIN {{ref("mart_capacite_dpt_reg_evol")}} t2 ON t1.cle_unique = t2.cle_unique +ORDER BY lit_hospi_complete diff --git a/models/schema.yml b/models/schema.yml index ef2eea7..9a51246 100644 --- a/models/schema.yml +++ b/models/schema.yml @@ -32,6 +32,18 @@ sources: - name: capacite_services_h schema: capacite_services_h tables: + - name: capacite_2022_par_services + identifier: capacite_2022_par_services + description: "Test" + - name: capacite_2022_par_etablissement + identifier: capacite_2022_par_etablissement + description: "Test" + - name: capacite_2022_etablissement_stjr + identifier: capacite_2022_etablissement_stjr + description: "Test" + - name: capacite_2021_service_stjr + identifier: capacite_2021_service_stjr + description: "Test" - name: capacite_services_dpt_region identifier: capacite_services_dpt_region description: 'test' diff --git a/models/staging/capacite_services_h/stg_capacite_services_h__capacite_2021_service_stjr.sql b/models/staging/capacite_services_h/stg_capacite_services_h__capacite_2021_service_stjr.sql new file mode 100644 index 0000000..0352a9f --- /dev/null +++ b/models/staging/capacite_services_h/stg_capacite_services_h__capacite_2021_service_stjr.sql @@ -0,0 +1,34 @@ +with + +source as ( + + select * from {{ source('capacite_services_h', 'capacite_2021_service_stjr') }} + +), + +renamed as ( + + select + an, + fi, + fi_ej, + stjr, + disci, + lit, + sejhc, + jou, + pla, + sejhp, + pas, + sejacc, + ivg, + sehem, + serad, + sechi, + discipline + + from source + +) + +select * from renamed diff --git a/models/staging/capacite_services_h/stg_capacite_services_h__capacite_2022_etablissement_stjr.sql b/models/staging/capacite_services_h/stg_capacite_services_h__capacite_2022_etablissement_stjr.sql new file mode 100644 index 0000000..6060f15 --- /dev/null +++ b/models/staging/capacite_services_h/stg_capacite_services_h__capacite_2022_etablissement_stjr.sql @@ -0,0 +1,41 @@ +with + +source as ( + + select * from {{ source('capacite_services_h', 'capacite_2022_etablissement_stjr') }} + +), + +renamed as ( + + select + fi, + an, + fi_ej, + rs, + grp, + stjr, + cat, + dep, + reg, + espic, + cominsee, + disci, + discipline, + lit, + sejhc, + jou, + pla, + sejhp, + pas, + sejacc, + ivg, + sehem, + serad, + sechi + + from source + +) + +select * from renamed diff --git a/models/staging/capacite_services_h/stg_capacite_services_h__capacite_2022_par_etablissement.sql b/models/staging/capacite_services_h/stg_capacite_services_h__capacite_2022_par_etablissement.sql new file mode 100644 index 0000000..189995d --- /dev/null +++ b/models/staging/capacite_services_h/stg_capacite_services_h__capacite_2022_par_etablissement.sql @@ -0,0 +1,39 @@ +with + +source as ( + + select * from {{ source('capacite_services_h', 'capacite_2022_par_etablissement') }} + +), + +renamed as ( + + select + fi, + an, + fi_ej, + rs, + stj, + cat, + dep, + reg, + anc_reg, + espic, + cominsee, + grp, + lit, + sejhc, + jou, + pla, + sejhp, + pas, + sejacc, + sehem, + serad, + sechi + + from source + +) + +select * from renamed diff --git a/models/staging/capacite_services_h/stg_capacite_services_h__capacite_2022_par_services.sql b/models/staging/capacite_services_h/stg_capacite_services_h__capacite_2022_par_services.sql new file mode 100644 index 0000000..6b48d6a --- /dev/null +++ b/models/staging/capacite_services_h/stg_capacite_services_h__capacite_2022_par_services.sql @@ -0,0 +1,42 @@ +with + +source as ( + + select * from {{ source('capacite_services_h', 'capacite_2022_par_services') }} + +), + +renamed as ( + + select + fi, + an, + fi_ej, + rs, + stj, + cat, + dep, + reg, + anc_reg, + espic, + cominsee, + grp, + disci, + discipline, + lit, + sejhc, + jou, + pla, + sejhp, + pas, + sejacc, + sehem, + serad, + sechi, + cle_unique + + from source + +) + +select * from renamed