Created
June 27, 2017 17:11
-
-
Save fyaconiello/82ad662322e080f14c9fd16c48ca1f7b to your computer and use it in GitHub Desktop.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
SELECT | |
SUM(p_tmhh.holding_pct * (s_sach.percentage / 100)) AS percentage | |
FROM | |
portfolio_trademodelholdinghistory AS p_tmhh | |
INNER JOIN security_datedim AS s_dd ON s_dd.id = p_tmhh.holding_date_id | |
INNER JOIN security_securityassetclasshistory s_sach ON s_sach.month_id = s_dd.month_id | |
AND s_sach.security_id = p_tmhh.security_id | |
INNER JOIN security_securitybreakdowntype AS s_sbt ON s_sbt.id = s_sach.securitybreakdowntype_id | |
INNER JOIN portfolio_investmentoffering AS p_io ON p_tmhh.trade_model_id = p_io.trade_model_id | |
INNER JOIN portfolio_offeringproducttype AS p_opt ON p_opt.id = p_io.product_type_id | |
INNER JOIN portfolio_offeringimplementationtype AS p_oit ON p_oit.id = p_io.implementation_type_id | |
WHERE | |
p_io.strategy_id = 1 | |
AND p_io.is_primary = 1 | |
AND s_sbt.CODE = "Web" | |
AND s_dd.id = 8767 | |
AND p_io.is_active = 1 | |
ORDER BY | |
s_dd.trade_date DESC | |
LIMIT 1 | |
-- AND s_sach.asset_class3_id = %d |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment