NULL Handling · Question 5 · Easy
NULL Handling question 5
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
What does this query return for the employee with id 2?
SELECT name, bonus + 1000
FROM Staff
WHERE id = 2;
- Bhavesh, 1000
- Bhavesh, NULL
- Bhavesh, 0
- No rows
Answer and explanation
Answer: B. Bhavesh, NULL
Explanation: Arithmetic with NULL gives NULL: unknown + 1000 is still unknown. The row itself is still returned, because the WHERE condition id = 2 is true.
Previous: Table Staff: id | name | dept | bonus 1 | Anita | HR | 5000 2 | Bhavesh | IT |… · Next: What does the function NULLIF(a, b) return?
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
- In SQL's three-valued logic, what does the comparison NULL = NULL evaluate to?
- 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 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 |…
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