Complete the code to group the sales by product.
SELECT product, SUM(amount) FROM sales [1] product;To group rows by a column, use GROUP BY.
Complete the code to order the grouped results by total sales descending.
SELECT product, SUM(amount) AS total FROM sales GROUP BY product [1] total DESC;To sort results, use ORDER BY followed by the column and direction.
Fix the error in the query to correctly group and order by the count of orders.
SELECT customer_id, COUNT(*) AS order_count FROM orders [1] customer_id ORDER BY order_count DESC;The query must use GROUP BY to group by customer_id before ordering.
Fill both blanks to group sales by region and order by average amount ascending.
SELECT region, AVG(amount) AS avg_amount FROM sales [1] region [2] avg_amount ASC;
Use GROUP BY to group by region and ORDER BY to sort by average amount.
Fill all three blanks to select product, count orders, and order by count descending.
SELECT [1], COUNT(*) AS [2] FROM orders [3] [1] ORDER BY [2] DESC;
Select the product column, name the count as order_count, and group by product to count orders per product.
