Skip to content

CS Professional · Artificial Intelligence, Data Analytics and Cyber Security - Laws and Practice · Database Management

A table EMP has 6 rows with salaries 20000, 30000, 30000, 40000, 50000 and NULL. Which of the following statements about the results is correct?

COUNT(*) returns 6 and COUNT(salary) returns 5. COUNT(*) counts every row including those with NULL, whereas COUNT on a column skips NULL values. COUNT(DISTINCT salary) would return 4 because duplicates and NULL are ignored.

  1. ACOUNT(*) returns 6 and COUNT(salary) returns 5Correct
  2. BCOUNT(*) returns 5 and COUNT(salary) returns 5
  3. CCOUNT(*) returns 6 and COUNT(salary) returns 6
  4. DCOUNT(DISTINCT salary) returns 5

Explanation

COUNT(*) counts all rows, giving 6. COUNT(salary) ignores NULLs, giving 5. COUNT(DISTINCT salary) ignores NULL and duplicates, giving 20000, 30000, 40000, 50000, which is 4, so the last option is wrong.

Did you get it right without looking?

One question tells you little. A timed set on Database Management shows your real accuracy, how long you take and where you lose marks.

More Database Management questions