diff options
Diffstat (limited to 'sql/et_tables.sql')
| -rw-r--r-- | sql/et_tables.sql | 6 |
1 files changed, 4 insertions, 2 deletions
diff --git a/sql/et_tables.sql b/sql/et_tables.sql index d5f8361c..eee1a42b 100644 --- a/sql/et_tables.sql +++ b/sql/et_tables.sql @@ -602,11 +602,13 @@ CREATE OR REPLACE FUNCTION historical_cusip_risk(p_date date, p_cusips VARIADIC BEGIN RETURN QUERY SELECT b.duration, b.delta, b.price, b.updatedate FROM (SELECT unnest(p_cusips) AS cusip, generate_subscripts(p_cusips, 1) AS id) a - LEFT JOIN (SELECT DISTINCT ON (cusip) * FROM et_cusip_model_numbers GROUP BY cusip, updatedate - HAVING updatedate <= p_date) AS b USING (cusip) ORDER BY id; + LEFT JOIN (SELECT DISTINCT ON (cusip) * FROM et_cusip_model_numbers WHERE updatedate<=p_date + ORDER BY cusip, updatedate DESC) + AS b USING (cusip) ORDER BY id; END $$ LANGUAGE plpgsql; + ALTER FUNCTION historical_cusip_risk(date, varchar(10)[]) OWNER TO et_user; |
