Question:medium

Assertion (A): The output of the SQL query SELECT COUNT (name) FROM students; will differ from the output of SELECT COUNT (*) FROM students; if there are some NULL values in the name column.

Reason (R): COUNT(column_name) returns the count of NON NULL values in that column, whereas COUNT(*) returns the number of records in the table.

Show Hint

COUNT(column) skips NULL values while COUNT(*) counts all rows. This is why the two outputs differ.
Updated On: Oct 20, 2026
  • Both (A) and (R) are True, and (R) correctly explains (A).
  • Both (A) and (R) are True, but (R) does not correctly explain (A).
  • (A) is True, but (R) is False.
  • (A) is False, but (R) is True.
Show Solution

The Correct Option is A

Solution and Explanation

Step 1: Build a tiny example:
Let the students table have 4 rows. The name column is 'Asha', 'Ravi', NULL, NULL.

Step 2: Run both queries by hand:
SELECT COUNT(name) FROM students; looks at the name column and ignores NULL. It returns 2.
SELECT COUNT(*) FROM students; counts the rows themselves. It returns 4.
The two results are different, so the Assertion holds.

Step 3: Read the Reason against this result:
The Reason says COUNT(column_name) counts non-NULL values and COUNT(*) counts all records. Our example agrees with this word for word. So the Reason is True.

Step 4: Link the two:
The gap between 2 and 4 is caused by the rule in the Reason. Nothing else causes it. So the Reason is the correct explanation of the Assertion.

Step 5: Rule out the other options:
Option (B) says R does not explain A, but it does. Option (C) says R is False, but it is True. Option (D) says A is False, but it is True.

Final Answer:
The answer is option (A).
Was this answer helpful?
0