CREATE OR REPLACE VIEW vu_fds_event_themes AS 
select	num_evenement,
	group_concat(theme) AS themes,
	count(num_evenement) AS nb_themes
FROM
	(select fds_evenement.num_evenement,
		evt_theme.theme
	FROM fds_evenement
	JOIN (select num_evenement,theme 
		FROM fds_evt_theme
		JOIN fds_theme ON fds_evt_theme.ref_theme = fds_theme.ref_theme) AS evt_theme
	ON fds_evenement.num_evenement = evt_theme.num_evenement) as tjoin
GROUP BY num_evenement
ORDER BY num_evenement;

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

