0
0
DBMS Theoryknowledge~10 mins

Aggregate functions (COUNT, SUM, AVG, MAX, MIN) in DBMS Theory - Interactive Code Practice

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

Complete the code to count all rows in the employees table.

DBMS Theory
SELECT [1](*) FROM employees;
Drag options to blanks, or click blank then click option'
AAVG
BSUM
CCOUNT
DMAX
Attempts:
3 left
💡 Hint
Common Mistakes
Using SUM instead of COUNT will cause an error or wrong result.
Using AVG or MAX does not count rows.
2fill in blank
medium

Complete the code to find the total salary from the salaries table.

DBMS Theory
SELECT [1](salary) FROM salaries;
Drag options to blanks, or click blank then click option'
ASUM
BCOUNT
CAVG
DMIN
Attempts:
3 left
💡 Hint
Common Mistakes
Using COUNT will count rows, not add values.
Using AVG will give average, not total.
3fill in blank
hard

Fix the error in the code to find the average age from the people table.

DBMS Theory
SELECT [1](age) FROM people;
Drag options to blanks, or click blank then click option'
ACOUNT
BAVG
CSUM
DMAX
Attempts:
3 left
💡 Hint
Common Mistakes
Using SUM or COUNT will not calculate average.
Using MAX returns the highest value, not average.
4fill in blank
hard

Fill both blanks to find the maximum and minimum prices from the products table.

DBMS Theory
SELECT [1](price) AS max_price, [2](price) AS min_price FROM products;
Drag options to blanks, or click blank then click option'
AMAX
BSUM
CMIN
DCOUNT
Attempts:
3 left
💡 Hint
Common Mistakes
Using SUM or COUNT instead of MAX or MIN.
Mixing up MAX and MIN functions.
5fill in blank
hard

Fill all three blanks to create a query that counts employees, sums their salaries, and finds the average age.

DBMS Theory
SELECT [1](*) AS total_employees, [2](salary) AS total_salary, [3](age) AS average_age FROM employees;
Drag options to blanks, or click blank then click option'
ACOUNT
BSUM
CAVG
DMIN
Attempts:
3 left
💡 Hint
Common Mistakes
Mixing up COUNT and SUM functions.
Using MIN instead of AVG for average calculation.