Hi all,

i have the following 3 tables;

AccountID, Name, Address

CorpBondID, Principal

CorpBondTransID, CorpBondID, AccountID, AllocatedPrincipal

The CorpID in t_corp_bond_trans is a foreign key from t_corp_bond table, and the AccountID is a foreign key from t_account table.

I am trying to build a query where i select only those rows in t_corp_trans rows where the Sum of AllocatedPrincipal in t_corp_trans is equal to the principal amount in t_corp where the CorpBondID in t_corp_bond table is equal to CorpBondID in the t_corp_bond_trans table.

i tried doing something like this with no luck;

select t_corp_bond_trans.* from t_corp_bond_trans, t_corp_bond
where t_corp_bond.CorpBondID= t_corp_bond_trans.CorpBondID
and t_corp_bond.Principal = (select SUM(t_corp_bond_trans.AllocatedPrincipal) where
t_corp_bond.CorpBondID = t_corp_bond_trans.CorpBondID
from t_corp_bond_trans)

Thanks in Advance for your help