0
0
SQLquery~10 mins

GROUP BY single column in SQL - Interactive Code Practice

Choose your learning style9 modes available
Practice - 5 Tasks
Answer the questions below
1fill in blank
easy

Complete the code to group the sales by the product column.

SQL
SELECT product, SUM(amount) FROM sales [1] product;
Drag options to blanks, or click blank then click option'
AWHERE
BORDER BY
CGROUP BY
DHAVING
Attempts:
3 left
💡 Hint
Common Mistakes
Using ORDER BY instead of GROUP BY
Using WHERE to filter groups
2fill in blank
medium

Complete the code to find the total quantity sold for each category.

SQL
SELECT category, SUM(quantity) FROM products [1] category;
Drag options to blanks, or click blank then click option'
AHAVING
BGROUP BY
CORDER BY
DWHERE
Attempts:
3 left
💡 Hint
Common Mistakes
Using HAVING without GROUP BY
Using WHERE to filter groups
3fill in blank
hard

Fix the error in the query to correctly group by the customer_id column.

SQL
SELECT customer_id, COUNT(order_id) FROM orders [1] customer_id;
Drag options to blanks, or click blank then click option'
AGROUP BY
BWHERE
CJOIN
DORDER BY
Attempts:
3 left
💡 Hint
Common Mistakes
Using ORDER BY instead of GROUP BY
Missing GROUP BY clause
4fill in blank
hard

Fill both blanks to group sales by region and calculate the average sales amount.

SQL
SELECT [1], AVG(amount) FROM sales [2] region;
Drag options to blanks, or click blank then click option'
Aregion
BORDER BY
CGROUP BY
Damount
Attempts:
3 left
💡 Hint
Common Mistakes
Not including the grouping column in SELECT
Using ORDER BY instead of GROUP BY
5fill in blank
hard

Fill all three blanks to select the department, count employees, and group by department.

SQL
SELECT [1], COUNT(employee_id) FROM employees [2] [3];
Drag options to blanks, or click blank then click option'
Adepartment
BGROUP BY
DORDER BY
Attempts:
3 left
💡 Hint
Common Mistakes
Using ORDER BY instead of GROUP BY
Not grouping by the selected column