for use of sum Function in query you have to use Group by
correct Query is belowing....
select a.CustomerName, SUM(a.TotalAmount) as TotalAmount, SUM(b.PaidAmount ) as PaidAmount
from CustomerDetails a join AmountMaster b on a.CustomerId=b.CustomerId where b.AmountTypeId=1 and b.PaymentToId=2 group by a.CustomerName
order by b.CustomerId