Computer Science
Below are the customer and order tables :
Customers
customer id (PK) |
---|
first_name |
last_name |
address |
city |
state |
zip |
Orders
order id (PK) |
---|
order_date |
amount |
customer_id (FK) |
List the total of customers' orders grouped by customer (id).
SQL Joins & Grouping
2 Likes
Answer
SELECT c.customer_id, COUNT(o.order_id) AS total_orders
FROM Customers c, orders o
WHERE c.customer_id = o.customer_id
GROUP BY c.customer_id;
Answered By
1 Like
Related Questions
List the sum of employees' salaries grouped by department. (table EMPL)
List the maximum salary of employee grouped by their department number.
Below are the customer and order tables :
Customers
customer id (PK) first_name last_name email address city state zip Orders
order id (PK) order_date amount customer_id (FK) List the sum of the totals of orders grouped by customer and state.
Below are the customer and order tables :
Customers
customer id (PK) first_name last_name email address city state zip Orders
order id (PK) order_date amount customer_id (FK) List the customers (name) and the total amount of all their orders.