Repaso
EspaƱol
Databases & SQLIntermediateDB-08

COUNT(*) vs COUNT(email)?

Options

  1. They are identical and always return the same number
  2. COUNT(*) counts all rows; COUNT(email) skips NULL emails (Correct option)
  3. COUNT(email) counts only the distinct emails
  4. COUNT(*) skips rows that contain any NULL

Answer

COUNT(*) counts all rows; COUNT(email) skips rows where email is NULL

Why

COUNT(*) counts rows, no matter what they contain.

COUNT(email) counts only rows where email has a value (not NULL). Most aggregate functions (SUM, AVG, COUNT(column)) ignore NULLs.

For unique values: COUNT(DISTINCT email).

Remember

COUNT(column) ignores NULLs.

Key terms

Practice this question in Repaso