CASE WHEN tiep.element_pedagogique_id is NULL THEN 0 ELSE 1 END has_type_intervention
from
chemin_pedagogique cp
JOIN element_pedagogique ep ON$af cp.element_pedagogique_id = ep.id AND ep.histo_destruction IS NULL$orEp
@@ -142,6 +143,7 @@ select * from (
JOIN GROUPE_TYPE_FORMATION gtf on tf.GROUPE_ID = gtf.ID
JOIN structure s ON s.id = e.structure_id OR s.id = ep.structure_id
LEFT JOIN periode pe ON ep.periode_id = pe.id
LEFT JOIN (SELECT DISTINCT element_pedagogique_id FROM type_intervention_ep WHERE histo_destruction IS NULL) tiep ON tiep.element_pedagogique_id = ep.id