CS FundamentalsModerateHCLTech · Infosys placement 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 product names 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 product names does this query return?
SELECT pname FROM Products WHERE pname LIKE '_e%';
- A. Pen, Desk, Chair
- B. Pen, Pencil, Desk
- C. Pen, Pencil
- D. Notebook, Desk
Correct answer: B. Pen, Pencil, Desk
The underscore matches exactly one character, so the SECOND letter of the name must be 'e': Pen (P-e-n), Pencil (P-e-n...) and Desk (D-e-s-k) qualify. Notebook's second letter is 'o', Laptop's is 'a', Chair's is 'h' and Mouse's is 'o'.
More DBMS and SQL questions
- Table Products(pid, pname, category, price, stock) rows: (1, 'Pen', 'Stationery', 10, 100), (2, 'Notebook', 'Stationery', 50, 0), (3…
- 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: