UPDATE
BondPrices
SET
MarketValueOwned = Holdings.Amount
FROM
BondPrices BondPrices
INNER JOIN
(
SELECT
PM.SecurityId,
SUM(Pos.QuantityTraded * Pos.Mark) AS Amount
FROM
Position Pos --WITH (NOLOCK, READUNCOMMITTED)
INNER JOIN
PositionMaster PM --WITH (NOLOCK, READUNCOMMITTED)
ON
Pos.PositionMasterId = PM.PositionMasterId
WHERE
Pos.Date = @ReportDate
GROUP BY
PM.SecurityId
) Holdings ON
BondPrices.SecurityId = Holdings.SecurityId
WHERE
BondPrices.Date = @ReportDate
UPDATE
BondPrices
SET
Mark