-- View: mf.vu_histo_surftot_par_maitrise

-- DROP VIEW mf.vu_histo_surftot_par_maitrise;

CREATE OR REPLACE VIEW mf.vu_histo_surftot_par_maitrise AS 
 SELECT type_maitrise.type_maitrise, count(acte.ref_type_maitrise) AS nb_parcel, sum(histo_parcelle.surface) AS surf_maitrise
   FROM mf.acte, mf.histo_parcelle, mf.type_maitrise
  WHERE histo_parcelle.code_acte::text = acte.code_acte::text AND acte.ref_type_maitrise = type_maitrise.id_type_maitrise
  GROUP BY type_maitrise.type_maitrise
  ORDER BY type_maitrise.type_maitrise;

ALTER TABLE mf.vu_histo_surftot_par_maitrise OWNER TO ludodo;
GRANT ALL ON TABLE mf.vu_histo_surftot_par_maitrise TO ludodo;
GRANT ALL ON TABLE mf.vu_histo_surftot_par_maitrise TO geomatique;
GRANT SELECT, REFERENCES, TRIGGER ON TABLE mf.vu_histo_surftot_par_maitrise TO public;
GRANT SELECT, REFERENCES, TRIGGER ON TABLE mf.vu_histo_surftot_par_maitrise TO cpnrc;

