Untitled
unknown
plain_text
4 days ago
699 B
2
Indexable
Never
SELECT settlement_date, settlement_period, price, otc_price FROM ( SELECT d.settlement_date, d.settlement_period, publish_date, price, ROW_NUMBER() OVER (PARTITION BY d.settlement_date, d.settlement_period ORDER BY publish_date DESC) AS rn FROM promptopt.popt_published_price p JOIN promptopt.popt_published_price_detail d USING (published_price_id) JOIN common.settlement_period sp ON sp.settlement_day = d.settlement_date AND sp.settlement_period = d.settlement_period WHERE publish_date <= efa_day - 1 + INTERVAL '11 hours 30 minutes' AND price <> 0 AND d.settlement_date BETWEEN DATE_TRUNC('day', CURRENT_DATE - 14) AND DATE_TRUNC('day', CURRENT_DATE - 1) ) WHERE rn = 1;
Leave a Comment