CBSE Class 12 Informatics Practices
Question 82 of 90
Querying Using SQL — Question 22
Back to all questions 22
Question 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 sum of the totals of orders where this sum is greater than $1000 grouped by customer (id) and state and ordered by state.
SELECT c.customer_id, c.state, SUM(o.amount)
FROM Customers c, orders o
WHERE c.customer_id = o.customer_id
GROUP BY c.customer_id, c.state
HAVING SUM(o.amount) > 1000
ORDER BY c.state;