0
0
SQLquery~10 mins

Why aggregation is needed in SQL - Test Your Understanding

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

Complete the code to calculate the total sales from the sales table.

SQL
SELECT [1](amount) FROM sales;
Drag options to blanks, or click blank then click option'
AMIN
BCOUNT
CMAX
DSUM
Attempts:
3 left
💡 Hint
Common Mistakes
Using COUNT counts rows, not sums values.
Using MAX or MIN returns only the highest or lowest value.
2fill in blank
medium

Complete the code to find how many orders are in the orders table.

SQL
SELECT [1](*) FROM orders;
Drag options to blanks, or click blank then click option'
ASUM
BAVG
CCOUNT
DMAX
Attempts:
3 left
💡 Hint
Common Mistakes
Using SUM tries to add values but * is not a column.
Using AVG or MAX does not count rows.
3fill in blank
hard

Fix the error in the code to find the average price from the products table.

SQL
SELECT [1](price) FROM products;
Drag options to blanks, or click blank then click option'
AAVG
BCOUNT
CSUM
DMIN
Attempts:
3 left
💡 Hint
Common Mistakes
Using SUM adds all prices instead of averaging.
Using COUNT counts rows, not values.
Using MIN finds the smallest price.
4fill in blank
hard

Fill both blanks to find the highest and lowest scores from the scores table.

SQL
SELECT [1](score), [2](score) FROM scores;
Drag options to blanks, or click blank then click option'
AMAX
BMIN
CSUM
DCOUNT
Attempts:
3 left
💡 Hint
Common Mistakes
Using SUM or COUNT does not find highest or lowest values.
Swapping MAX and MIN changes the meaning.
5fill in blank
hard

Fill all three blanks to create a query that shows each department, the number of employees, and the average salary from the employees table.

SQL
SELECT [1], [2](employee_id), [3](salary) FROM employees GROUP BY [1];
Drag options to blanks, or click blank then click option'
Adepartment
BCOUNT
CAVG
DSUM
Attempts:
3 left
💡 Hint
Common Mistakes
Using SUM instead of AVG for salary.
Not grouping by department.
Counting salary instead of employee_id.