GROUP BY + an aggregate function
SELECT customer_id, SUM(amount)
FROM table
GROUP BY customer_id
will group up all repeating rows into one and sum their amounts into one — select the customer_id and take the sum of the amount column from the table grouped by the customer_id
some SQL engines need you to select the column you are grouping by
We use cookies to understand our websites traffic and offer our website visitors personalized experience. To find out more, click ‘More Information’. In addition, please, read our
Privacy policy.