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