CREATE OR REPLACE VIEW vu_fds_event_etablis_sco AS 
select	num_evenement,
	group_concat(scolaire) AS typ_etablissements,
	count(num_evenement) AS nb_typ_etablis
FROM
	(select fds_evenement.num_evenement,
		evt_scolaire.scolaire
	FROM fds_evenement
	JOIN (select num_evenement,scolaire 
		FROM fds_evt_scolaire
		JOIN fds_scolaire ON fds_evt_scolaire.ref_scolaire = fds_scolaire.ref_scolaire) AS evt_scolaire
	ON fds_evenement.num_evenement = evt_scolaire.num_evenement) as tjoin
GROUP BY num_evenement
ORDER BY num_evenement;

ALTER TABLE vu_fds_event_etablis_sco
  OWNER TO postgres;
GRANT ALL ON TABLE vu_vds_event_alljoin TO postgres;
GRANT SELECT, INSERT, REFERENCES, TRIGGER ON TABLE vu_vds_event_alljoin TO public;

