Management & CommerceVery hardBusiness analyst · SQL test
Table p(id, cat) has ids 1, 2, 3 in category X, ids 4, 5 in Y and id 6 in Z. How many rows does SELECT * FROM p a JOIN p b ON a.cat = b.cat AND a.id < b.id return?
- A. 8
- B. 4
- C. 6
- D. 14
Correct answer: B. 4
Each unordered pair within a category appears once: X has 3 pairs, Y has 1, Z none – 4 in total. Using a.id <> b.id counts each pair twice (8); with no id condition, each row also pairs with itself (14).
Practise more Operations, Supply Chain & Business Analytics questionsOperations, Supply Chain & Business Analytics: notes and key points
More Operations, Supply Chain & Business Analytics questions
- Table e(name, s) has salaries A 90, B 90, C 80, D 70. What do these return? P: SELECT DISTINCT s FROM e ORDER BY s DESC LIMIT 1 OFFSET 1…
- A column holds the names Sara, Raman, Ria, Kavya and Ana. How many of them match LIKE '%a' (assume a case-insensitive comparison)?
- A firm orders 1,000 units at a time. At this quantity its annual holding cost is ₹6,000 and its annual ordering cost is ₹3,000. Without…
- A three-server bank counter (M/M/3) has arrivals of 24 per hour and each teller serves 10 per hour. On average, how many tellers are busy?
- A ward has 20 beds, the average length of stay is 4 days and the hospital targets 85% average occupancy. How many admissions per day can…
- Products A and B use machines M1 and M2, each available 480 minutes a day. A needs 4 min on M1 and 2 min on M2; B needs 2 min on M1 and 5…