0
0
SQLquery~10 mins

COUNT function behavior 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 count all rows in the table named 'employees'.

SQL
SELECT COUNT([1]) FROM employees;
Drag options to blanks, or click blank then click option'
Aname
Bsalary
Cid
D*
Attempts:
3 left
💡 Hint
Common Mistakes
Using COUNT(column_name) when you want to count all rows including NULLs.
Leaving the parentheses empty inside COUNT.
2fill in blank
medium

Complete the code to count only the non-NULL values in the 'salary' column from 'employees'.

SQL
SELECT COUNT([1]) FROM employees;
Drag options to blanks, or click blank then click option'
A*
Bsalary
CNULL
DDISTINCT salary
Attempts:
3 left
💡 Hint
Common Mistakes
Using COUNT(*) when only non-NULL values are needed.
Using COUNT(NULL) which always returns 0.
3fill in blank
hard

Fix the error in the code to count distinct non-NULL 'department' values in 'employees'.

SQL
SELECT COUNT([1]) FROM employees;
Drag options to blanks, or click blank then click option'
ADISTINCT department
Bdepartment
C*
DALL department
Attempts:
3 left
💡 Hint
Common Mistakes
Using COUNT(department) which counts all non-NULL but not distinct values.
Using COUNT(*) which counts all rows regardless of department.
4fill in blank
hard

Fill both blanks to count how many employees have a non-NULL 'email' and a salary greater than 50000.

SQL
SELECT COUNT([1]) FROM employees WHERE [2] > 50000;
Drag options to blanks, or click blank then click option'
Aemail
Bsalary
Attempts:
3 left
💡 Hint
Common Mistakes
Using COUNT(*) which counts all rows regardless of email NULLs.
Using WHERE email > 50000 which is invalid.
5fill in blank
hard

Fill all three blanks to count distinct non-NULL 'manager_id' values for employees with 'status' = 'active'.

SQL
SELECT COUNT([1]) FROM employees WHERE [2] = [3];
Drag options to blanks, or click blank then click option'
ADISTINCT manager_id
Bstatus
C'active'
Dmanager_id
Attempts:
3 left
💡 Hint
Common Mistakes
Using COUNT(manager_id) which counts duplicates.
Using WHERE status = active without quotes causing syntax error.