CS FundamentalsHardTCS Digital · Infosys SP · GATE CS

Table Product(pid, cat, price) rows: (1, 'X', 10), (2, 'X', 20), (3, 'Y', 20), (4, NULL, 30), (5, 'Y', NULL), (6, 'Z', 5). How many rows does this query return?

Table Product(pid, cat, price) rows: (1, 'X', 10), (2, 'X', 20), (3, 'Y', 20), (4, NULL, 30), (5, 'Y', NULL), (6, 'Z', 5). How many rows does this query return?
SELECT cat, COUNT(*)
FROM Product
GROUP BY cat
HAVING AVG(price) > 12;
  1. A. 3
  2. B. 2
  3. C. 1
  4. D. 4

Correct answer: A. 3

Groups: X avg 15, Y avg 20 (NULL ignored), NULL-category group avg 30, Z avg 5. Three groups pass, including the NULL group.

More DBMS and SQL questions

Exams that ask this topic