Management & CommerceVery hardBusiness analyst · SQL test
cust has Asha (1), Ravi (2) and Meena (3); ord has orders 10 and 11 for customer 1 and order 12 for customer 3. A report uses SELECT c.name, COUNT(*), COUNT(o.oid) FROM cust c LEFT JOIN ord o ON c.id = o.cid GROUP BY c.id. What does it show for Ravi?
- A. COUNT(*) = 0 and COUNT(o.oid) = 0
- B. COUNT(*) = 1 and COUNT(o.oid) = 0
- C. Ravi does not appear
- D. COUNT(*) = 1 and COUNT(o.oid) = 1
Correct answer: B. COUNT(*) = 1 and COUNT(o.oid) = 0
The LEFT JOIN keeps Ravi with one row of NULLs. COUNT(*) counts that row (1), but COUNT(o.oid) skips NULLs (0). Using COUNT(*) here would wrongly show Ravi as having one order.
Practise more Operations, Supply Chain & Business Analytics questionsOperations, Supply Chain & Business Analytics: notes and key points
More Operations, Supply Chain & Business Analytics questions
- prod(pid, name) has Pen (1), Book (2) and Bag (3); sales(pid, qty) has rows (1, 5), (1, 3), (2, 4). How many rows do these return? P…
- Daily demand is normal. About what percentage of days have demand within 1.5 standard deviations of the mean? (Φ(1.5) ≈ 0.9332.)
- A team compares two suppliers' processes for the same part: Process P has Cp = 1.8 and Cpk = 0.9; Process Q has Cp = 1.3 and Cpk = 1.25…
- An item is ordered 20 times a year. Holding cost is ₹8 per unit per year and each unit short costs ₹30. Expected units short per cycle for…
- A single-server desk (M/M/1) has λ = 8 per hour and μ = 10 per hour. In an M/M/1 queue, time in system is exponential with mean 1/(μ − λ)…
- A clinic with 3 doctors receives 12 patients an hour. On average there are 6 patients in the clinic, of whom 4 are waiting (not with a…