CREATE OR REPLACE VIEW vu_fds_event_partenaires AS 
select	num_evenement,
	group_concat(partenaire) AS partenaires,
	count(num_evenement) AS nb_partenaires
FROM
	(select fds_evenement.num_evenement,
		evt_partenaire.organisme AS partenaire
	FROM fds_evenement
	JOIN (select num_evenement,organisme 
		FROM fds_evt_intervenant
		JOIN fds_intervenants ON fds_evt_intervenant.ref_intervenant = fds_intervenants.ref_intervenant) AS evt_partenaire
	ON fds_evenement.num_evenement = evt_partenaire.num_evenement) as tjoin
GROUP BY num_evenement
ORDER BY num_evenement;

ALTER TABLE vu_fds_event_partenaires
  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;

