0
0
MySQLquery~10 mins

SUM function in MySQL - 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.

MySQL
SELECT SUM([1]) FROM employees;
Drag options to blanks, or click blank then click option'
Aname
Bsalary
Cdepartment
Demployee_id
Attempts:
3 left
💡 Hint
Common Mistakes
Using a non-numeric column like name or department inside SUM.
Forgetting to specify the column inside SUM.
2fill in blank
medium

Complete the code to find the total sales from the orders table.

MySQL
SELECT SUM([1]) FROM orders;
Drag options to blanks, or click blank then click option'
Aorder_date
Border_id
Ccustomer_id
Dtotal_amount
Attempts:
3 left
💡 Hint
Common Mistakes
Using a date or ID column inside SUM.
Confusing column names that do not hold numeric values.
3fill in blank
hard

Fix the error in the code to correctly sum the prices in the products table.

MySQL
SELECT SUM([1]) FROM products;
Drag options to blanks, or click blank then click option'
Aprice
Bproduct_name
Ccategory
Dstock
Attempts:
3 left
💡 Hint
Common Mistakes
Trying to sum text columns like product_name or category.
Using a column that is not numeric.
4fill in blank
hard

Fill both blanks to calculate the total quantity sold for product_id 101 in sales table.

MySQL
SELECT SUM([1]) FROM sales WHERE [2] = 101;
Drag options to blanks, or click blank then click option'
Aquantity
Bprice
Cproduct_id
Dcustomer_id
Attempts:
3 left
💡 Hint
Common Mistakes
Summing the price instead of quantity.
Filtering by the wrong column in WHERE clause.
5fill in blank
hard

Fill all three blanks to calculate the total revenue for customer 'John' in orders table.

MySQL
SELECT SUM([1]) FROM orders WHERE [2] = '[3]';
Drag options to blanks, or click blank then click option'
Atotal_amount
Bcustomer_name
CJohn
Dorder_date
Attempts:
3 left
💡 Hint
Common Mistakes
Using wrong columns in SUM or WHERE clause.
Forgetting to put quotes around the string 'John'.