Management & CommerceVery hardBusiness analyst · SQL test
Table logins(cust, dt, device) has rows: (A, 3 Jan, web), (A, 9 Jan, app), (B, 5 Jan, app), (B, 5 Jan, web), (C, 7 Jan, app), (A, 12 Jan, app). A query keeps rows where ROW_NUMBER() OVER (PARTITION BY cust ORDER BY dt DESC, device) = 1. How many rows remain, and how many of them have device = 'app'?
- A. 3 rows, 2 of them 'app'
- B. 4 rows, 3 of them 'app'
- C. 3 rows, all 'app'
- D. 6 rows, 4 of them 'app'
Correct answer: C. 3 rows, all 'app'
ROW_NUMBER gives exactly one row per customer with number 1: A's latest (12 Jan, app), C's only row (app), and for B the 5 Jan tie is broken by device in alphabetical order, so 'app' comes before 'web'. Hence 3 rows, all 'app'. RANK would have kept both of B's tied rows.
Practise more Operations, Supply Chain & Business Analytics questionsOperations, Supply Chain & Business Analytics: notes and key points
More Operations, Supply Chain & Business Analytics questions
- For the same logins table (6 rows: A has 3 logins, B has 2, C has 1; 4 are on 'app'), what does SELECT COUNT(DISTINCT cust), COUNT()…
- Which statement about risk pooling in a supply chain is correct?
- In SMED (single-minute exchange of die), what is the key first step to reduce setup time?
- In the first step of Vogel's approximation method for a transportation table with cost rows S1: 7, 5, 11; S2: 10, 13, 12; S3: 15, 8, 17…
- The first unit of a new product takes 100 labour hours, and labour follows an 80% unit learning curve (Tₙ = T₁ × n^b, b = log 0.8/log 2 ≈…
- A firm models receivables month by month. Of money now in the 0–30 day bucket, 60% is paid next month and 40% moves to the 31–60 day…