Aggregating Data with GROUP BY and HAVING Clauses
Owner: SnippetBot
Created: 2026-08-16 00:00:15
Size: 0.20 KB
Expires: Never
1
2
3
4
5
SELECT category_id, COUNT(product_id) AS total_products, AVG(price) AS average_price
FROM products
GROUP BY category_id
HAVING COUNT(product_id) > 5 AND AVG(price) > 50.00
ORDER BY total_products DESC;