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;
- A. Stationery only
- B. Stationery and Electronics
- C. Electronics only
- 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
- Why does adding an index on a frequently-UPDATEd or frequently-INSERTed column have a real cost, beyond the storage the index itself uses?
- ARIES recovery uses a Log Sequence Number (LSN) stored on each data page, recording the LSN of the last log record that modified that…
- ARIES recovery performs three phases on restart: analysis, redo, then undo. Why must redo happen BEFORE undo, rather than undoing first…
- A Compensation Log Record (CLR) in ARIES, written while undoing a transaction's update, includes a field pointing to the next log record…
- Write-ahead logging (WAL) requires that:
- A fuzzy checkpoint in ARIES records the set of active (dirty) transactions and dirty pages at checkpoint time WITHOUT forcing all dirty…