Given the following table:
EMPLOYEE
ENO SALARY A101 4000 B109 NULL C508 6000 A305 2000
State the output of the following query based on the above given table.
SELECT COUNT(SALARY) FROM EMPLOYEE;
Given the following table:
EMPLOYEE
| ENO | SALARY |
|---|---|
| A101 | 4000 |
| B109 | NULL |
| C508 | 6000 |
| A305 | 2000 |
State the output of the following query based on the above given table.
SELECT COUNT(SALARY) FROM EMPLOYEE;
Solution
✅ Correct Option: 3
COUNT(column) counts only the non-NULL values in that column. SALARY has the values 4000, 6000 and 2000, and the NULL for B109 is skipped, so the result is 3.
Option 1: 4 is the result of COUNT(*), which counts all rows including those with NULL.
Related questions:
2025: 21 May Shift 1
2026: 23 May Shift 1
2026: 26 May Shift 1