Consider the following table named "MANAGER".
ID MANAGERNAME 1 AMIT 2 ANIL 3 SUMAN 4 NULL
The number of rows returned by following SQL statement is____________ .
SELECT COUNT(MANAGERNAME) FROM MANAGER;
Consider the following table named "MANAGER".
| ID | MANAGERNAME |
|---|---|
| 1 | AMIT |
| 2 | ANIL |
| 3 | SUMAN |
| 4 | NULL |
The number of rows returned by following SQL statement is____________ .
SELECT COUNT(MANAGERNAME) FROM MANAGER;
Solution
COUNT(column_name) counts only the non-NULL values in that column. MANAGERNAME has AMIT, ANIL and SUMAN as non-NULL values, and the fourth row is NULL, so it is skipped.
Option 2: 4 is what COUNT() would give, because COUNT() counts every row, including those with NULL.
We believe the answer should be Option 3, since an aggregate query without GROUP BY returns a single row (holding the value 3), so the number of rows returned is 1. However, NTA's final answer key (after all challenges) says Option 1.
Related questions:
2025: 30 May Shift 2
2026: 11 May Shift 2
2025: 22 May Shift 1
2025: 22 May Shift 1
2026: 18 May Shift 2
2025: 20 May Shift 1