-- View: vu_mf_surftot_par_maitrise

-- DROP VIEW vu_mf_surftot_par_maitrise;

CREATE OR REPLACE VIEW mf.vu_surftot_par_maitrise AS 
 SELECT mf.type_maitrise.type_maitrise,
		count(mf.acte.ref_type_maitrise) AS nb_parcel,
		sum(mf.parcelle.surface) AS surf_maitrise
   FROM mf.acte, mf.parcelle, mf.type_maitrise
  WHERE mf.parcelle.code_acte::text = mf.acte.code_acte::text
  AND mf.acte.ref_type_maitrise = mf.type_maitrise.id_type_maitrise
  GROUP BY type_maitrise
  ORDER BY type_maitrise;
  
ALTER TABLE mf.vu_surftot_par_maitrise OWNER TO ludodo;
GRANT ALL ON TABLE mf.vu_surftot_par_maitrise TO ludodo;
GRANT SELECT, REFERENCES, TRIGGER ON TABLE mf.vu_surftot_par_maitrise TO public;
GRANT SELECT, REFERENCES, TRIGGER ON TABLE mf.vu_surftot_par_maitrise TO cpnrc;

