Calculate Cumulative Sum for Each Integer in Table
Company: Coinbase
Role: Data Scientist
Category: Data Manipulation (SQL/Python)
Difficulty: medium
Interview Round: Onsite
Overview: This question evaluates competency in cumulative aggregation and ordering within SQL and related data-manipulation tools, focusing on calculating running totals across rows. It is commonly asked to measure practical application skills in the Data Manipulation (SQL/Python) domain, testing query formulation, efficiency and aggregation semantics at a practical application level.
Tables
numbers(num INTEGER)
Hints
- Use a window function: SUM(num) OVER with ORDER BY num to compute a running total.
- Use a RANGE frame to include all rows with equal values (≤ current value).