3
You can do this using the function SUM
and grouping the records by the field you want with GROUP BY
. Example:
SELECT `customer_id`, SUM(`amount`) AS `amount`
FROM `tb_customer_credit`
GROUP BY `customer_id`;
So you have the sum of all the records. If you need the sum of only one record, you can do it the way @Bernardokowacic did, using the WHERE
.
You need to add all the
amount
that has the samecustomer_id
?– KaduAmaral
Yes, I think it would be more or less like the answer below.
– concas