-
Notifications
You must be signed in to change notification settings - Fork 0
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
- Loading branch information
laurinehu
committed
Oct 30, 2023
1 parent
62560fa
commit 7aca442
Showing
4 changed files
with
80 additions
and
62 deletions.
There are no files selected for viewing
This file was deleted.
Oops, something went wrong.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,51 @@ | ||
select | ||
ctr.contrat_id_ctr, | ||
ctr.contrat_id_structure, | ||
ctr.contrat_id_pph, | ||
ctr.contrat_date_embauche, | ||
emi.emi_afi_id, | ||
emi.emi_sme_annee, | ||
emi.emi_sme_mois, | ||
af.af_numero_annexe_financiere, | ||
salarie.genre_salarie, | ||
salarie.tranche_age, | ||
salarie.qpv, | ||
salarie.zrr, | ||
rnf.rnf_libelle_niveau_form_empl as niveau_formation_salarie, | ||
struct.structure_denomination, | ||
struct.structure_adresse_admin_commune, | ||
struct.structure_adresse_admin_code_insee, | ||
app_geo.code_dept as departement_structure, | ||
app_geo.nom_departement as nom_departement_structure, | ||
app_geo.code_region as region_structure, | ||
app_geo.nom_region as nom_region_structure, | ||
app_geo.nom_epci as epci_structure, | ||
case | ||
when ctr.contrat_salarie_rqth then 'OUI' | ||
else 'NON' | ||
end as salarie_rqth, | ||
case | ||
when ctr.contrat_salarie_rsa = 'OUI-M' then 'OUI' | ||
when ctr.contrat_salarie_rsa = 'OUI-NM' then 'OUI' | ||
else 'NON' | ||
end as salarie_brsa, | ||
split_part(ctr.contrat_mesure_disp_code, '_', 1) as type_structure_entree, | ||
date_trunc('month', to_date(ctr.contrat_date_embauche, 'DD/MM/YYYY')) as mois_entree | ||
from {{ source('fluxIAE', 'fluxIAE_ContratMission') }} as ctr | ||
left join {{ source('fluxIAE', 'fluxIAE_EtatMensuelIndiv') }} as emi | ||
on ctr.contrat_id_pph = emi.emi_pph_id and ctr.contrat_id_ctr = emi.emi_ctr_id | ||
left join {{ ref('fluxIAE_AnnexeFinanciere_v2') }} as af | ||
on emi.emi_afi_id = af.af_id_annexe_financiere | ||
left join {{ ref('stg_salarie') }} as salarie | ||
on ctr.contrat_id_pph = salarie.salarie_id | ||
left join {{ source('fluxIAE', 'fluxIAE_RefNiveauFormation') }} as rnf | ||
on ctr.contrat_niveau_de_formation_code = rnf.rnf_id | ||
left join {{ source('fluxIAE', 'fluxIAE_Structure') }} as struct | ||
on ctr.contrat_id_structure = struct.structure_id_siae | ||
left join {{ ref('stg_insee_appartenance_geo_communes') }} as app_geo | ||
on struct.structure_adresse_admin_code_insee = app_geo.code_insee | ||
where | ||
ctr.contrat_type_contrat = 0 | ||
and af.af_etat_annexe_financiere_code in ( | ||
'VALIDE', 'PROVISOIRE', 'CLOTURE' | ||
) |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,8 +1,28 @@ | ||
/* This table is needed to gather the gender of all the distincts employees in the asp flux | ||
Indeed, some employees are referenced more than once which induces a wrong amount of ETP per gender */ | ||
|
||
select distinct | ||
salarie.salarie_id, | ||
salarie.salarie_rci_libelle | ||
salarie.salarie_rci_libelle, | ||
salarie.salarie_codeinseecom, | ||
salarie.salarie_commune as commune, | ||
ltrim(salarie.salarie_code_dpt, '0') as departement, | ||
case | ||
when salarie.salarie_rci_libelle = 'MME' then 'Femme' | ||
when salarie.salarie_rci_libelle = 'M.' then 'Homme' | ||
else 'Non renseigné' | ||
end as genre_salarie, | ||
case | ||
when (date_part('year', current_date) - salarie.salarie_annee_naissance) <= 25 then 'a- Moins de 26 ans' | ||
when (date_part('year', current_date) - salarie.salarie_annee_naissance) >= 26 and (date_part('year', current_date) - salarie.salarie_annee_naissance) <= 30 then 'b- Entre 26 ans et 30 ans' | ||
when (date_part('year', current_date) - salarie.salarie_annee_naissance) >= 31 and (date_part('year', current_date) - salarie.salarie_annee_naissance) <= 50 then 'c- Entre 31 ans et 50 ans' | ||
when (date_part('year', current_date) - salarie.salarie_annee_naissance) >= 51 then 'd- 51 ans et plus' | ||
else 'autre' | ||
end as tranche_age, | ||
case | ||
when salarie.salarie_adr_qpv_type = 'QP' then 'Oui' | ||
else 'Non' | ||
end as qpv, | ||
case | ||
when salarie.salarie_adr_is_zrr = 'true' then 'Oui' | ||
else 'Non' | ||
end as zrr | ||
from | ||
{{ source('fluxIAE', 'fluxIAE_Salarie') }} as salarie | ||
{{ ref('fluxIAE_Salarie_v2') }} as salarie |