diff options
Diffstat (limited to 'sql/dawn.sql')
| -rw-r--r-- | sql/dawn.sql | 19 |
1 files changed, 11 insertions, 8 deletions
diff --git a/sql/dawn.sql b/sql/dawn.sql index f98dfdf2..207f6bdf 100644 --- a/sql/dawn.sql +++ b/sql/dawn.sql @@ -4853,16 +4853,16 @@ CREATE TABLE irs_tickets ( CREATE OR REPLACE VIEW globeop_forward_valuations AS -SELECT periodenddate, fund, invccy, invid, port, strat, sum(endlocalmv) as endlocalmv +SELECT periodenddate, fund, invccy, invid, port::text, strat::text, sum(endlocalmv) as endlocalmv FROM valuation_reports vr GROUP BY invccy, invid, periodenddate, fund, port, strat HAVING invid IN ('EURF') ORDER BY periodenddate desc, fund; -CREATE OR REPLACE VIEW citco_forward_valuation +CREATE OR REPLACE VIEW citco_forward_valuations AS SELECT cr.period_end_date AS periodenddate, cr.fund, - "substring"(cr.bloomberg_code, 0, 4) AS invccy, + "substring"(cr.bloomberg_code, 0, 4)::currency AS invccy, "substring"(cr.bloomberg_code, 0, 4) || 'F'::text AS invid, split_part(cr.strategy, '/'::text, 1) AS port, split_part(cr.strategy, '/'::text, 2) AS strat, @@ -4872,7 +4872,11 @@ AS SELECT HAVING cr.bloomberg_code ~~ '%CURNCY'::text ORDER BY cr.period_end_date DESC, fund; -CREATE OR REPLACE VIEW globeop_otc_valuations AS SELECT periodenddate, fund, invccy, custacctname, port, strat, +CREATE OR REPLACE VIEW admin_forward_valuations +AS SELECT * FROM globeop_forward_valuations UNION SELECT * FROM citco_forward_valuations ORDER BY periodenddate desc, fund; + + +CREATE OR REPLACE VIEW globeop_otc_valuations AS SELECT periodenddate, fund, invccy, custacctname, port::text, strat::text, sum( CASE WHEN endbookmv = 0 OR endlocalmv = 0 THEN 0 @@ -4923,25 +4927,24 @@ AS SELECT cr.period_end_date AS periodenddate, GROUP BY cr.period_end_date, cr.fund, cr.symbol, cr.trade_ccy, cr."prime_broker/clearing_broker" HAVING cr.symbol = ANY (ARRAY['EUR Cash Balance'::text, 'USD Cash Balance'::text]) ORDER BY period_end_date DESC, fund; - CREATE VIEW eur_fx_valuations AS SELECT periodenddate, fund, port, forward_valuations, otc_valuations, cash_valuations FROM ( SELECT periodenddate, fund, port, sum(endlocalmv) AS forward_valuations - FROM admin_forward_valuations + FROM globeop_forward_valuations WHERE invid = 'EURF' GROUP BY periodenddate, fund, port ) f FULL OUTER JOIN ( SELECT periodenddate, fund, port, sum(endlocalmv) AS otc_valuations - FROM admin_otc_valuations + FROM globeop_otc_valuations WHERE invccy = 'EUR' GROUP BY periodenddate, fund, port ) otc USING (periodenddate, fund, port) FULL OUTER JOIN ( SELECT periodenddate, fund, port, sum(endlocalmv) AS cash_valuations - FROM admin_cash_valuations + FROM globeop_cash_valuations UNION citco_cash_valuations WHERE invid = 'EUR' GROUP BY periodenddate, fund, port ) c |
