0
0
SQLquery~10 mins

SUM function 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 calculate the total salary from the employees table.

SQL
SELECT [1](salary) FROM employees;
Drag options to blanks, or click blank then click option'
ASUM
BCOUNT
CAVG
DMAX
Attempts:
3 left
💡 Hint
Common Mistakes
Using COUNT instead of SUM will count rows, not add values.
Using AVG will give the average, not the total.
2fill in blank
medium

Complete the code to find the total price of all products in the products table.

SQL
SELECT [1](price) AS total_price FROM products;
Drag options to blanks, or click blank then click option'
ASUM
BCOUNT
CMIN
DAVG
Attempts:
3 left
💡 Hint
Common Mistakes
Using COUNT will count the number of products, not sum their prices.
Using AVG will calculate the average price, not the total.
3fill in blank
hard

Fix the error in the code to correctly calculate the total quantity from the orders table.

SQL
SELECT [1](quantity) FROM orders;
Drag options to blanks, or click blank then click option'
ACOUNT
BTOTAL
CGROUP
DSUM
Attempts:
3 left
💡 Hint
Common Mistakes
Using COUNT will count rows, not sum values.
Using TOTAL is not a valid SQL function.
4fill in blank
hard

Fill both blanks to calculate the total sales for each product in the sales table.

SQL
SELECT product_id, [1](amount) AS total_amount FROM sales [2] product_id;
Drag options to blanks, or click blank then click option'
ASUM
BCOUNT
CGROUP BY
DORDER BY
Attempts:
3 left
💡 Hint
Common Mistakes
Using COUNT instead of SUM will count rows, not sum amounts.
Using ORDER BY instead of GROUP BY will sort results but not group them.
5fill in blank
hard

Fill all three blanks to calculate the total revenue for each category in the products table.

SQL
SELECT [1], [2](price) AS total_revenue FROM products [3] category;
Drag options to blanks, or click blank then click option'
Acategory
BSUM
CGROUP BY
DORDER BY
Attempts:
3 left
💡 Hint
Common Mistakes
Using ORDER BY instead of GROUP BY will not group results.
Forgetting to select the category column will lose grouping context.