+ 1
[SOLVED] How to make a sum selection of tuples with relational algebre
I have a table of customers and I want to know the total amount each client spent . I can make a sum for all the column amount, or just for one customer with the clause "where id_customer=x" but how to make the sum for each customer?
3 Answers
+ 15
use SUM and GROUP BY together
SELECT customer_id, SUM(order_amount)
FROM orders
GROUP BY customer_id;
this might help:
https://www.w3resource.com/sql/aggregate-functions/sum-with-group-by.php
+ 9
great :)
marked as solved for anyone else who encounter this problem (and search for it <.<)
+ 1
thank you guys, Burey have the solution.