homework 2

Lena Fischer 11 months ago
parent 4dd5fbab70 commit 780614e9a30a2f4732c6afd88c9b0ea241d55698
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;