Practice free →
HomeGATE CSEcomputerscienceDatabase Management Systems › In a 100-row `employees` table where 20 rows hav…

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.
Solve this in the app — GATE CSE practice & 24k+ MCQs →
Related questions