NULL Handling · Question 7 · Easy
NULL Handling question 7
Table Staff:
id | name | dept | bonus
1 | Anita | HR | 5000
2 | Bhavesh | IT | NULL
3 | Charu | IT | 8000
4 | Deepak | Sales | NULL
5 | Esha | HR | 3000
How many rows does this query count?
SELECT COUNT(*)
FROM Staff
WHERE bonus <> 5000;
- 2
- 4
- 3
- 0
Answer and explanation
Answer: A. 2
Explanation: bonus <> 5000 is TRUE only for Charu (8000) and Esha (3000). For Bhavesh and Deepak the comparison with NULL is UNKNOWN, so those rows are not counted.
Previous: What does the function NULLIF(a, b) return? · Next: Table Staff: id | name | dept | bonus 1 | Anita | HR | 5000 2 | Bhavesh | IT |…
Practise null handling
Try a fresh set of null handling questions with an explanation after every answer, free and without signing up: NULL Handling practice. Or sit a full placement mock test.
More null handling questions
- Table Staff: id | name | dept | bonus 1 | Anita | HR | 5000 2 | Bhavesh | IT |…
- Table Staff: id | name | dept | bonus 1 | Anita | HR | 5000 2 | Bhavesh | IT |…
- What does the function NULLIF(a, b) return?
- Table Staff: id | name | dept | bonus 1 | Anita | HR | 5000 2 | Bhavesh | IT |…
- Table Staff: id | name | dept | bonus 1 | Anita | HR | 5000 2 | Bhavesh | IT |…
- Table Staff: id | name | dept | bonus 1 | Anita | HR | 5000 2 | Bhavesh | IT |…
- Table Parcel: id | city | agent 1 | Pune | Ravi 2 | Pune | NULL 3 | Indore |…
- Table Staff: id | name | dept | bonus 1 | Anita | HR | 5000 2 | Bhavesh | IT |…
- Table Feedback: id | student | rating 1 | Tanvi | 4 2 | Umesh | 0 3 | Varun |…
- Table Customer: id | name | mobile | email 1 | Farhan | 9810012345 | NULL 2 |…
More sql practice
SQL Functions & CASE · UNION, INTERSECT & EXCEPT · Tables, Keys & Constraints · DML & Transactions · SELECT, WHERE & ORDER BY · SQL Joins · Aggregates & GROUP BY · Subqueries & CTEs
LogicWiz Exams home · All practice topics · Placement mock tests · Daily 10 challenge