Management & CommerceVery hardBusiness analyst · SQL test
Using table v, how many rows do these return? P: SELECT * FROM v WHERE amt > 60; Q: SELECT city, SUM(amt) FROM v GROUP BY city HAVING SUM(amt) > 60.
- A. P = 3, Q = 2
- B. P = 3, Q = 3
- C. P = 4, Q = 2
- D. P = 4, Q = 3
Correct answer: A. P = 3, Q = 2
P filters rows: 100, 200 and 80 exceed 60 (D's NULL does not), so 3. Q groups first: Pune 150, NULL group 280, Goa NULL; HAVING keeps Pune and the NULL group, so 2. GROUP BY treats all NULL cities as one group, and SUM over only NULLs is NULL.
Practise more Operations, Supply Chain & Business Analytics questionsOperations, Supply Chain & Business Analytics: notes and key points
More Operations, Supply Chain & Business Analytics questions
- Table m(store, mon, rev) has S1: month 1 = 100, month 2 = 120, month 3 = 90; S2: month 1 = 200, month 2 = 180. What does rev − LAG(rev)…
- Using table v (where Goa's only row has amt NULL), what do SELECT SUM(amt) FROM v WHERE city = 'Goa' and SELECT COALESCE(SUM(amt), 0) FROM…
- A subscription business started the quarter with 1,000 customers, gained 200 new customers during the quarter and ended with 1,050…
- While solving a transportation problem with 3 sources and 4 destinations, an initial solution has only 5 occupied cells. What should be…
- In the Hungarian method for a 5 × 5 assignment problem, after row and column reductions all zeros can be covered by 4 lines. What does…
- A plant runs at 80% utilisation and its average queue of jobs is 4 hours of work. Management plans to load it to 95% utilisation. Assuming…