+ 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?

4th Jan 2018, 7:05 AM
Jacinto Lima
Jacinto Lima - avatar
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
4th Jan 2018, 7:24 AM
Burey
Burey - avatar
+ 9
great :) marked as solved for anyone else who encounter this problem (and search for it <.<)
4th Jan 2018, 1:00 PM
Burey
Burey - avatar
+ 1
thank you guys, Burey have the solution.
4th Jan 2018, 12:17 PM
Jacinto Lima
Jacinto Lima - avatar