Start learning →

In a 100-row `employees` table where 20 rows have `salary` NULL,

ACOUNT(*) = 100 and COUNT(salary) = 80
BCOUNT(*) = 80 and COUNT(salary) = 100
CCOUNT(*) = 100 and COUNT(salary) = 100
Dboth return NULL because of the NULL salaries
Answer & Solution
Correct answer: A. COUNT(*) = 100 and COUNT(salary) = 80
COUNT(*) counts rows, regardless of NULL values inside them, so all 100 rows are counted. COUNT(salary) counts rows where the salary column is NOT NULL so it skips the 20 NULL-salary rows and returns 80. This pair is a common GATE trap.
Practise this question with Quill — GATE CSE →

Keep practising Database Management Systems

Browse all Database Management Systems questions for GATE CSE, or explore more Computer Science topics.

Start a Database Management Systems lesson →
Related questions