-- View: vu_mf_surftot_par_site

-- DROP VIEW vu_mf_surftot_par_site;

CREATE OR REPLACE VIEW mf.vu_histo_surftot_par_site AS 
 SELECT mf.histo_parcelle.code_site, sites.libl_site, count(mf.histo_parcelle.code_site) AS nb_parcel, sum(mf.histo_parcelle.surface) AS tot_surf
   FROM mf.histo_parcelle, sites
  WHERE mf.histo_parcelle.code_site::bpchar = sites.code_site
  GROUP BY mf.histo_parcelle.code_site, sites.libl_site
  ORDER BY mf.histo_parcelle.code_site;

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