SQL: GROUP BY and HAVING
A short, tested SQL example for group by and having. Copy it and adjust the names and paths for your project.
SQL
SELECT customer_id, COUNT(*) AS orders, SUM(total) AS spent
FROM orders
GROUP BY customer_id
HAVING SUM(total) > 1000
ORDER BY spent DESC;Find it in Zest
Search for “sql group by and having” in Zest and this example appears above the results, with other matches to choose from. Searches stay private.