How to use sum function in joins in sql server 2008?
SELECT SUM(d.TranTypeAmt),
h.LnNo,
h.LoanRcptAmt,
d.Trantype,
d.TranTypeAmt
FROM LGen_LnInstClln_h h
RIGHT OUTER JOIN LGen_LnInstClln_d d
ON h.PK_Id = d.InstCllnHdr_FK
WHERE h.LnNo = '40009'
You should have a group by clause when using aggregate function, with other columns in the select list.
so here you should add
at the end of the query