src: | SELECT t_places.type_sejour_id, t_type_sejour.code AS type_sejour_code, t_type_sejour.texte AS type_sejour_texte, t_type_sejour.section_id AS type_sejour_section_id, t_type_sejour.section_code AS type_sejour_section_code, t_type_sejour.section_texte AS type_sejour_section_texte, t_places.parent_id, t_places_parents.parent_code, t_places_parents.parent_texte, t_places_parents.parent_section_id, t_places_parents.parent_section_code, t_places_parents.parent_section_texte, t_places.date, t_places.jour_semaine, t_places.is_weekend, t_places.nb_lits_theoriques, t_places.nb_lits_cp_theoriques, t_places.nb_lits_ouverts, t_places.nb_lits_cp_ouverts, t_places.est_ouvert, t_places.heberge_hospitalises, t_places.heberge_ambulatoires, t_places.heberge_externes, t_places.heberge_bebes, t_places.heberge_urgences, t_places.heberge_seances, t_places_parents.parent_type, CASE WHEN t_places_parents.parent_type = 'ETA'::text THEN t_places.parent_id ELSE - 111::bigint END AS etage_id, CASE WHEN t_places_parents.parent_type = 'ETA'::text THEN t_places_parents.parent_code ELSE ''::text END AS etage_code, CASE WHEN t_places_parents.parent_type = 'ETA'::text THEN t_places_parents.parent_texte ELSE ''::text END AS etage_texte, CASE WHEN t_places_parents.parent_type = 'ETA'::text THEN t_places_parents.parent_section_id ELSE ARRAY[- 111::bigint, - 111::bigint, - 111::bigint, - 111::bigint, - 111::bigint, - 111::bigint, - 111::bigint, - 111::bigint, - 111::bigint, - 111::bigint] END AS etage_section_id, CASE WHEN t_places_parents.parent_type = 'ETA'::text THEN t_places_parents.parent_section_code ELSE ARRAY[''::text, ''::text, ''::text, ''::text, ''::text, ''::text, ''::text, ''::text, ''::text, ''::text] END AS etage_section_code, CASE WHEN t_places_parents.parent_type = 'ETA'::text THEN t_places_parents.parent_section_texte ELSE ARRAY[''::text, ''::text, ''::text, ''::text, ''::text, ''::text, ''::text, ''::text, ''::text, ''::text] END AS etage_section_texte, CASE WHEN t_places_parents.parent_type = 'SER'::text THEN t_places.parent_id ELSE - 111::bigint END AS service_id, CASE WHEN t_places_parents.parent_type = 'SER'::text THEN t_places_parents.parent_code ELSE ''::text END AS service_code, CASE WHEN t_places_parents.parent_type = 'SER'::text THEN t_places_parents.parent_texte ELSE ''::text END AS service_texte, CASE WHEN t_places_parents.parent_type = 'SER'::text THEN t_places_parents.parent_section_id ELSE ARRAY[- 111::bigint, - 111::bigint, - 111::bigint, - 111::bigint, - 111::bigint, - 111::bigint, - 111::bigint, - 111::bigint, - 111::bigint, - 111::bigint] END AS service_section_id, CASE WHEN t_places_parents.parent_type = 'SER'::text THEN t_places_parents.parent_section_code ELSE ARRAY[''::text, ''::text, ''::text, ''::text, ''::text, ''::text, ''::text, ''::text, ''::text, ''::text] END AS service_section_code, CASE WHEN t_places_parents.parent_type = 'SER'::text THEN t_places_parents.parent_section_texte ELSE ARRAY[''::text, ''::text, ''::text, ''::text, ''::text, ''::text, ''::text, ''::text, ''::text, ''::text] END AS service_section_texte, CASE WHEN t_places_parents.parent_type = 'UF'::text THEN t_places.parent_id ELSE - 111::bigint END AS uf_id, CASE WHEN t_places_parents.parent_type = 'UF'::text THEN t_places_parents.parent_code ELSE ''::text END AS uf_code, CASE WHEN t_places_parents.parent_type = 'UF'::text THEN t_places_parents.parent_texte ELSE ''::text END AS uf_texte, CASE WHEN t_places_parents.parent_type = 'UF'::text THEN t_places_parents.parent_section_id ELSE ARRAY[- 111::bigint, - 111::bigint, - 111::bigint, - 111::bigint, - 111::bigint, - 111::bigint, - 111::bigint, - 111::bigint, - 111::bigint, - 111::bigint] END AS uf_section_id, CASE WHEN t_places_parents.parent_type = 'UF'::text THEN t_places_parents.parent_section_code ELSE ARRAY[''::text, ''::text, ''::text, ''::text, ''::text, ''::text, ''::text, ''::text, ''::text, ''::text] END AS uf_section_code, CASE WHEN t_places_parents.parent_type = 'UF'::text THEN t_places_parents.parent_section_texte ELSE ARRAY[''::text, ''::text, ''::text, ''::text, ''::text, ''::text, ''::text, ''::text, ''::text, ''::text] END AS uf_section_texte, CASE WHEN t_places_parents.parent_type = 'UM'::text THEN t_places.parent_id ELSE - 111::bigint END AS um_id, CASE WHEN t_places_parents.parent_type = 'UM'::text THEN t_places_parents.parent_code ELSE ''::text END AS um_code, CASE WHEN t_places_parents.parent_type = 'UM'::text THEN t_places_parents.parent_texte ELSE ''::text END AS um_texte, CASE WHEN t_places_parents.parent_type = 'UM'::text THEN t_places_parents.parent_section_id ELSE ARRAY[- 111::bigint, - 111::bigint, - 111::bigint, - 111::bigint, - 111::bigint, - 111::bigint, - 111::bigint, - 111::bigint, - 111::bigint, - 111::bigint] END AS um_section_id, CASE WHEN t_places_parents.parent_type = 'UM'::text THEN t_places_parents.parent_section_code ELSE ARRAY[''::text, ''::text, ''::text, ''::text, ''::text, ''::text, ''::text, ''::text, ''::text, ''::text] END AS um_section_code, CASE WHEN t_places_parents.parent_type = 'UM'::text THEN t_places_parents.parent_section_texte ELSE ARRAY[''::text, ''::text, ''::text, ''::text, ''::text, ''::text, ''::text, ''::text, ''::text, ''::text] END AS um_section_texte, t_places_parents.mode_traitement_id, t_places_parents.mode_traitement_code, t_places_parents.mode_traitement_texte, t_places_parents.finess_id, t_places_parents.finess_code, t_places_parents.finess_texte, t_places_parents.finess_section_id, t_places_parents.finess_section_code, t_places_parents.finess_section_texte, t_places.pole_id, t_pole.code AS pole_code, t_pole.texte AS pole_texte, t_pole.section_id AS pole_section_id, t_pole.section_code AS pole_section_code, t_pole.section_texte AS pole_section_texte FROM activite.t_places JOIN activite.t_type_sejour ON t_type_sejour.oid = t_places.type_sejour_id JOIN activite.t_places_parents ON t_places.parent_id = t_places_parents.oid LEFT JOIN base.t_pole ON t_places.pole_id = t_pole.oid;