Skip to main contentSkip to solution

Consider the following table named "MANAGER".

IDMANAGERNAME
1AMIT
2ANIL
3SUMAN
4NULL

The number of rows returned by following SQL statement is____________ .

SELECT COUNT(MANAGERNAME) FROM MANAGER;

Solution

✅ Correct Option: 1

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.

COUNT(MANAGERNAME)=1+1+1+0=3\text{COUNT(MANAGERNAME)} = 1 + 1 + 1 + 0 = \boxed{3}


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.

Keyboard Shortcuts

  • Left arrow: Previous question
  • Right arrow: Next question
  • S key: Jump to solution
  • Q key: Jump to question