NULL Handling · Question 15 · Medium

NULL Handling question 15

A table Voter has 10 rows, and the city column is NULL in exactly 3 of them. The query SELECT COUNT(*) FROM Voter WHERE city = 'Pune' returns 4. What does SELECT COUNT(*) FROM Voter WHERE city <> 'Pune' return?

  1. 6
  2. 7
  3. 3
  4. 0
Answer and explanation

Answer: C. 3

Explanation: The 3 NULL rows satisfy neither city = 'Pune' nor city <> 'Pune', because both comparisons are UNKNOWN for them. That leaves 10 - 4 - 3 = 3 rows with a known city other than Pune.

Previous: Table Customer: id | name | mobile | email 1 | Farhan | 9810012345 | NULL 2 |… · Next: Table Student: roll | name 1 | Irfan 2 | Jaya 3 | Kunal 4 | Lata Table Hostel…

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

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