Skip to main contentSkip to solution

Consider the following table 'Student':

Student

IDNAME
1NULL
NULLAMIT

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 2\boxed{2}.


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.

Keyboard Shortcuts

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