DROP MATERIALIZED VIEW costs_pm_mv ;

CREATE MATERIALIZED VIEW costs_pm_mv
   BUILD IMMEDIATE
   REFRESH FAST ON DEMAND
   ENABLE QUERY REWRITE
   AS
   SELECT DBMS_MVIEW.PMARKER(c.rowid) AS pmarker_costs,
          prod_name, SUM( unit_cost) AS sum_units,
          COUNT(unit_cost) AS count_units, COUNT(*) AS cnt
   FROM   costs c, products p
   WHERE c.prod_id = p.prod_id
   GROUP BY prod_name, DBMS_MVIEW.PMARKER(c.rowid);