SELECT SUM(A.amount) FROM (
SELECT amount, notes FROM credit WHERE customer_Id = $cust_id
UNION ALL
SELECT amount, notes FROM payment WHERE customer_Id = $cust_id
UNION ALL
SELECT sum( amount ), '' AS totalpaid FROM payment WHERE customer_Id = $cust_id
UNION ALL
SELECT sum( amount ), '' AS totaltaken FROM credit WHERE customer_Id = $cust_id
) A
;
Regards, Arun Kumar.A