homework 2

Emma Walsh 11 months ago
parent c23b7ead94 commit 36d357754594c029a6210a11ea08cd6d6ffdb5f1
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;