AnalystPath

Cumulative Downloads per Platform

SQLMediumMid level~15 min

Problem

Table: `DailyInstalls`

```text
+--------------+---------+
| Column | Type |
+--------------+---------+
| app_name | varchar |
| platform | varchar |
| log_day | date |
| installs | int |
+--------------+---------+
(platform, log_day) is the primary key. Each row gives the number of installs
recorded for an app on a given platform ('iOS' or 'Android') on a given day.
```

For each platform and each day, report the **running total of installs** on that platform up to and including that day. Name the running total `cumulative_installs`.

Return the result ordered by `platform`, then by `log_day`.

**Example**

```text
DailyInstalls:
+----------+----------+------------+----------+
| app_name | platform | log_day | installs |
+----------+----------+------------+----------+
| Lumio | iOS | 2022-05-01 | 100 |
| Pixly | Android | 2022-05-01 | 50 |
| Lumio | iOS | 2022-05-02 | 30 |
| Pixly | Android | 2022-05-02 | 40 |
+----------+----------+------------+----------+

Output:
+----------+------------+---------------------+
| platform | log_day | cumulative_installs |
+----------+------------+---------------------+
| Android | 2022-05-01 | 50 |
| Android | 2022-05-02 | 90 |
| iOS | 2022-05-01 | 100 |
| iOS | 2022-05-02 | 130 |
+----------+------------+---------------------+
```

Tables

Example rows — the live problem includes the full dataset.

DailyInstalls
app_nameplatformlog_dayinstalls
LumioiOS2022-05-01100
PixlyAndroid2022-05-0150
LumioiOS2022-05-0230

Expected output

Your answer should return 4 rows with the columns platform, log_day, cumulative_installs.

Starter code (SQL)

SELECT *
FROM DailyInstalls;

Solve this SQL question free

Write SQL and run it instantly in your browser — even on your phone. No signup needed to try.

Solution & explanation

Create a free account to unlock the optimal solution, a step-by-step explanation, and the hidden test cases that grade your answer.

Sign up free to unlock

Related SQL questions