Based on your explanation, didn't quite understand what kind of result you would like to have. An example for the original data and the desired result would help. Anyhow, just guessing the need here so have you tried using partitioning. Something like:
select broker,
cap,
sum(shares) over (partition by broker)
from table