Practice - 5 Tasks
Answer the questions below
1fill in blank
easyComplete 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'
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.
✗ Incorrect
The COUNT function counts the number of rows in a table or group.
2fill in blank
mediumComplete 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'
Attempts:
3 left
💡 Hint
Common Mistakes
Using COUNT will count rows, not add values.
Using AVG will give average, not total.
✗ Incorrect
The SUM function adds all values in a column.
3fill in blank
hardFix 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'
Attempts:
3 left
💡 Hint
Common Mistakes
Using SUM or COUNT will not calculate average.
Using MAX returns the highest value, not average.
✗ Incorrect
The AVG function calculates the average value of a column.
4fill in blank
hardFill 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'
Attempts:
3 left
💡 Hint
Common Mistakes
Using SUM or COUNT instead of MAX or MIN.
Mixing up MAX and MIN functions.
✗ Incorrect
MAX finds the highest value, and MIN finds the lowest value in a column.
5fill in blank
hardFill 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'
Attempts:
3 left
💡 Hint
Common Mistakes
Mixing up COUNT and SUM functions.
Using MIN instead of AVG for average calculation.
✗ Incorrect
This query uses COUNT to count employees, SUM to add salaries, and AVG to find average age.