0
0
SQLquery~10 mins

AVG 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 average salary from the employees table.

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

Complete the code to find the average age of users who are active.

SQL
SELECT AVG(age) FROM users WHERE status = [1];
Drag options to blanks, or click blank then click option'
A'active'
B'inactive'
C'pending'
D'banned'
Attempts:
3 left
💡 Hint
Common Mistakes
Using the wrong status value will give incorrect or empty results.
Forgetting quotes around string values causes syntax errors.
3fill in blank
hard

Fix the error in the code to correctly calculate the average price from products.

SQL
SELECT [1]price) FROM products;
Drag options to blanks, or click blank then click option'
AAVG
BSUM
CAVG(
DCOUNT
Attempts:
3 left
💡 Hint
Common Mistakes
Missing parentheses causes syntax errors.
Using SUM or COUNT changes the meaning of the query.
4fill in blank
hard

Fill both blanks to calculate the average score for students with scores greater than 70.

SQL
SELECT [1](score) FROM students WHERE score [2] 70;
Drag options to blanks, or click blank then click option'
AAVG
BSUM
C>
D<
Attempts:
3 left
💡 Hint
Common Mistakes
Using SUM instead of AVG changes the result.
Using < instead of > selects wrong scores.
5fill in blank
hard

Fill all three blanks to calculate the average rating for products with rating above 4 and category 'electronics'.

SQL
SELECT [1](rating) FROM products WHERE rating [2] 4 AND category = [3];
Drag options to blanks, or click blank then click option'
AAVG
B>
C'electronics'
D<
Attempts:
3 left
💡 Hint
Common Mistakes
Using < instead of > for rating condition.
Forgetting quotes around the category string.
Using SUM instead of AVG.