Management & CommerceHardBusiness analyst · SQL test
Table v(cust, city, amt) has rows (A, Pune, 100), (B, NULL, 200), (C, Pune, 50), (D, Goa, NULL), (E, NULL, 80). What does SELECT COUNT(DISTINCT city), COUNT(city), COUNT(*) FROM v return?
- A. 2, 3, 5
- B. 3, 5, 5
- C. 2, 5, 5
- D. 3, 3, 5
Correct answer: A. 2, 3, 5
COUNT(DISTINCT city) counts distinct non-NULL values: Pune and Goa (2). COUNT(city) counts non-NULL entries (3). COUNT(*) counts rows (5). NULL is never counted as a distinct value.
Practise more Operations, Supply Chain & Business Analytics questionsOperations, Supply Chain & Business Analytics: notes and key points
More Operations, Supply Chain & Business Analytics questions
- Using the same table v, what does CASE WHEN amt >= 100 THEN 'High' WHEN amt >= 50 THEN 'Mid' ELSE 'Low' END return for customers C and D?
- 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…
- 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…