CREATE OR REPLACE VIEW public.vw_utility_price_curve_prices AS
 WITH lastprice AS (
         SELECT ppv_1.price,
            max(ppv_1.price_date) AS max_price_date
           FROM price_price_value ppv_1
          WHERE (ppv_1.active = true)
          GROUP BY ppv_1.price
        )
 SELECT pp.id AS "intPriceCurveId",
    ppv.price_date AS "dtmPriceDate",
    (ppv.high_price)::numeric(18,6) AS "dblHighPrice",
    (ppv.low_price)::numeric(18,6) AS "dblLowPrice",
    (ppv.open_price)::numeric(18,6) AS "dblOpenPrice",
    (ppv.price_value)::numeric(18,6) AS "dblPriceValue",
    lp.max_price_date AS "dtmMaxPriceDate",
        CASE
            WHEN (ppv.price_date = lp.max_price_date) THEN true
            ELSE false
        END AS "ysnIsLatestPrice"
   FROM ((price_price pp
     LEFT JOIN price_price_value ppv ON (((pp.id = ppv.price) AND (ppv.active = true))))
     LEFT JOIN lastprice lp ON ((ppv.price = lp.price)))
  WHERE ((1 = 1) AND (pp.active = true));;
