Skip to content
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.

Commit 130a7d3

Browse files
authoredJun 30, 2021
add results tables
1 parent 71adea2 commit 130a7d3

File tree

1 file changed

+12
-3
lines changed

1 file changed

+12
-3
lines changed
 

‎bigquery/yoy.md‎

Lines changed: 12 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,5 @@
11
# Year-on-year percentage difference
2-
2+
To explore this example with some demo data, head [here](https://count.co/n/7I6eHGEwxX3?vm=e).
33

44
# Description
55
Calculating the year-on-year change of a quantity typically requires a few steps:
@@ -46,7 +46,11 @@ select
4646
from spotify.spotify_daily_tracks
4747
group by 1,3
4848
```
49-
49+
| year | sum_streams | artist |
50+
| --- | ----------- | ---- |
51+
| 2020-01-01 | 115372043 | CJ |
52+
| 2021-01-01 | 179284925 | CJ |
53+
| ... | ... | ... |
5054
```sql
5155
-- with_perc_diff
5256
select
@@ -59,4 +63,9 @@ from (
5963
from raw
6064
order by artist, year desc
6165
)
62-
```
66+
```
67+
| year | sum_streams | artist | last_year_total | perc_diff |
68+
| --- | ----------- | ---- | ---- | ----- |
69+
| 2020-01-01 | 115372043 | CJ | NULL | NULL |
70+
| 2021-01-01 | 179284925 | CJ | 115372043 | 55.397200515899684 |
71+
| ... | ... | ... | ... | .... |

0 commit comments

Comments
 (0)
Please sign in to comment.