homework 2

Fatima Zahra 1 year ago
parent ee01bd306b commit a231d9c5fe48bb40525142f35acb9af26ac38a24
1 changed files with 7 additions and 0 deletions
+7-0homework-2.sql ADDED
View File
@@ -0,0 +1,7 @@
1+-- Homework 2
2+-- Total per customer, only customers who spent more than 100
3+SELECT c.name, SUM(o.total) AS spent
4+FROM customers c JOIN orders o ON o.customer_id = c.id
5+GROUP BY c.id
6+HAVING spent > 100
7+ORDER BY spent DESC;