0
0
SQLquery~10 mins

Combining multiple aggregates 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 number of orders.

SQL
SELECT COUNT([1]) FROM orders;
Drag options to blanks, or click blank then click option'
A*
Border_id
Ccustomer_id
Dorder_date
Attempts:
3 left
💡 Hint
Common Mistakes
Using COUNT(*) counts all rows but here we want to specify the column explicitly.
Using a column that can have null values may give incorrect counts.
2fill in blank
medium

Complete the code to find the average order amount.

SQL
SELECT AVG([1]) FROM orders;
Drag options to blanks, or click blank then click option'
Aorder_amount
Border_date
Ccustomer_id
Dorder_id
Attempts:
3 left
💡 Hint
Common Mistakes
Using a non-numeric column causes errors.
Choosing the wrong column leads to meaningless results.
3fill in blank
hard

Fix the error in the code to get the maximum and minimum order amounts.

SQL
SELECT MAX(order_amount) AS max_amount, MIN([1]) AS min_amount FROM orders;
Drag options to blanks, or click blank then click option'
Acustomer_id
Border_id
Corder_date
Dorder_amount
Attempts:
3 left
💡 Hint
Common Mistakes
Using different columns for MAX and MIN causes inconsistent results.
Using non-numeric columns causes errors.
4fill in blank
hard

Fill both blanks to calculate the total and average order amounts.

SQL
SELECT [1](order_amount) AS total, [2](order_amount) AS average FROM orders;
Drag options to blanks, or click blank then click option'
ASUM
BAVG
CCOUNT
DMAX
Attempts:
3 left
💡 Hint
Common Mistakes
Using COUNT instead of SUM for total.
Mixing up AVG and MAX functions.
5fill in blank
hard

Fill all three blanks to calculate the total orders, average amount, and maximum amount.

SQL
SELECT [1](order_id) AS total_orders, [2](order_amount) AS avg_amount, [3](order_amount) AS max_amount FROM orders;
Drag options to blanks, or click blank then click option'
ACOUNT
BAVG
CMAX
DMIN
Attempts:
3 left
💡 Hint
Common Mistakes
Using SUM instead of COUNT for total orders.
Using MIN instead of MAX for maximum amount.