CS FundamentalsModerateAccenture · Capgemini technical pattern
Table Orders(id, cust, city, amount) rows: (1, 'Ana', 'Pune', 500), (2, 'Ben', 'Delhi', NULL), (3, 'Ana', 'Pune', 300), (4, 'Chen', 'Delhi', 700), (5, 'Dia', NULL, 200), (6, 'Ben', 'Delhi', 700). Table Customers(name, tier) rows: ('Ana', 'Gold'), ('Ben', 'Silver'), ('Eve', 'Gold'). How many rows does this query return?
Table Orders(id, cust, city, amount) rows: (1, 'Ana', 'Pune', 500), (2, 'Ben', 'Delhi', NULL), (3, 'Ana', 'Pune', 300), (4, 'Chen', 'Delhi', 700), (5, 'Dia', NULL, 200), (6, 'Ben', 'Delhi', 700).
Table Customers(name, tier) rows: ('Ana', 'Gold'), ('Ben', 'Silver'), ('Eve', 'Gold').
How many rows does this query return?
SELECT cust FROM Orders UNION SELECT name FROM Customers;
- A. 5
- B. 9
- C. 7
- D. 4
Correct answer: A. 5
UNION removes duplicates: Ana, Ben, Chen, Dia (from Orders) plus Eve (new from Customers) = 5. 9 is UNION ALL (6 + 3).
More DBMS and SQL questions
- Table Orders(id, cust, city, amount) rows: (1, 'Ana', 'Pune', 500), (2, 'Ben', 'Delhi', NULL), (3, 'Ana', 'Pune', 300), (4, 'Chen'…
- Table Orders(id, cust, city, amount) rows: (1, 'Ana', 'Pune', 500), (2, 'Ben', 'Delhi', NULL), (3, 'Ana', 'Pune', 300), (4, 'Chen'…
- Table Orders(id, cust, city, amount) rows: (1, 'Ana', 'Pune', 500), (2, 'Ben', 'Delhi', NULL), (3, 'Ana', 'Pune', 300), (4, 'Chen'…
- Table Orders(id, cust, city, amount) rows: (1, 'Ana', 'Pune', 500), (2, 'Ben', 'Delhi', NULL), (3, 'Ana', 'Pune', 300), (4, 'Chen'…
- R(A, B, C, D, E) has functional dependencies A → BC, CD → E and B → D. Which of the following is a candidate key?
- Account X holds 100. T1 reads X (100); T2 reads X (100); T1 writes X = 150 and commits; T2 writes X = 80 and commits. What is the final…