Consider the following table 'Student':
Student
ID NAME 1 NULL NULL AMIT
What will be the output of the following SQL statement?
SELECT COUNT(*) from Student;
Consider the following table 'Student':
Student
| ID | NAME |
|---|---|
| 1 | NULL |
| NULL | AMIT |
What will be the output of the following SQL statement?
SELECT COUNT(*) from Student;
Solution
✅ Correct Option: 3
COUNT(*) counts every row in the table, whether or not its columns contain NULL values. The table has 2 rows, (1, NULL) and (NULL, AMIT), so the output is .
Option 2 (1): this would be the result of COUNT(ID) or COUNT(NAME), which skip NULLs. Each column has only one non-NULL value, but COUNT(*) does not look at individual columns.
COUNT(*) counts rows, while COUNT(column) counts only the non-NULL values in that column.
Related questions:
2026: 23 May Shift 2
2026: 29 May Shift 1