CS FundamentalsModerateAccenture · Capgemini pattern

Table Products(pid, pname, category, price, stock) rows: (1, 'Pen', 'Stationery', 10, 100), (2, 'Notebook', 'Stationery', 50, 0), (3, 'Laptop', 'Electronics', 50000, 5), (4, 'Mouse', 'Electronics', 500, NULL), (5, 'Chair', 'Furniture', 2000, 20), (6, 'Desk', 'Furniture', NULL, 3), (7, 'Pencil', 'Stationery', 5, 200). Which categories does this query return?

Table Products(pid, pname, category, price, stock) rows: (1, 'Pen', 'Stationery', 10, 100), (2, 'Notebook', 'Stationery', 50, 0), (3, 'Laptop', 'Electronics', 50000, 5), (4, 'Mouse', 'Electronics', 500, NULL), (5, 'Chair', 'Furniture', 2000, 20), (6, 'Desk', 'Furniture', NULL, 3), (7, 'Pencil', 'Stationery', 5, 200). Which categories does this query return?
SELECT category FROM Products
GROUP BY category
HAVING COUNT(*) > 2;
  1. A. Stationery only
  2. B. Stationery and Electronics
  3. C. Electronics only
  4. D. All three categories

Correct answer: A. Stationery only

Stationery has 3 rows (Pen, Notebook, Pencil); Electronics and Furniture each have only 2. Only Stationery's count exceeds 2.

More DBMS and SQL questions

Exams that ask this topic