aboutsummaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
-rw-r--r--sql/dawn.sql3
1 files changed, 2 insertions, 1 deletions
diff --git a/sql/dawn.sql b/sql/dawn.sql
index e4d80e57..014fe8ed 100644
--- a/sql/dawn.sql
+++ b/sql/dawn.sql
@@ -1039,10 +1039,11 @@ LEFT JOIN (SELECT * FROM index_quotes WHERE date=p_date) d USING (index, series,
LEFT JOIN valuation_reports ON invid = a.globeop_id
LEFT JOIN (SELECT dealid, SUM(termination_amount) AS terminated_amount
FROM terminations WHERE termination_date <= p_date GROUP BY dealid) e USING (dealid)
-LEFT JOIN external_deriv_marks f ON a.cpty_id = f.identifier
+LEFT JOIN external_marks_deriv f ON identifier=cpty_id AND f.date=p_date
WHERE a.notional IS DISTINCT FROM terminated_amount
AND a.expiration_date > p_date AND trade_date <= p_date
AND swap_type = 'CD_INDEX_OPTION'
+AND periodenddate <= p_date
ORDER BY dealid, date DESC, periodenddate DESC;
END
$$ LANGUAGE plpgsql;