Management & CommerceHardBusiness analyst · SQL test
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 v WHERE city = 'Goa' return?
- A. 0 and 0
- B. NULL and NULL
- C. 0 and NULL
- D. NULL and 0
Correct answer: D. NULL and 0
SUM ignores NULLs, but when every input value is NULL (or there are no rows) it returns NULL, not 0. COALESCE converts that NULL to 0, which is what a report usually wants.
Practise more Operations, Supply Chain & Business Analytics questionsOperations, Supply Chain & Business Analytics: notes and key points
More Operations, Supply Chain & Business Analytics questions
- 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…
- A supply chain shares point-of-sale data and builds a joint forecast with its retailer, agreeing on replenishment plans together. Which…
- A lean programme wants to halve a part's economic lot size without changing demand or holding cost. By how much must the setup (ordering)…