I have a mysql table name payment (contains payments made by the customer) and another table called lead (contains customers). When the customer makes a payment it will be added in the payment table with customer id row by row. I want to fetch the sum of the paid amount of the particular customer using the customer_id.
How can I do it with mysql SUM function ?
As simple as that:
An explicit GROUP BY is not needed in this case, because mysql assumes the right thing automatically. May be needed in a more complex query.
Start by reading the manual here.