I have a table in BigQuery which gets new data daily and appends it to the current table. This table is called : score_FULL
. Additionally, I keep the individual scores on a daily basis, which can be accessed by score_20180125
if we choose today's date. Daily scores are appended to score_FULL
on a daily basis.
score_FULL
contains:
visitorID score
#Older scores first
1 0.15
2 0.78
3 0.12
6 0.90
------------------------
2 0.22
6 0.65
7 0.61
10 0.24
------------------------
1 0.31
2 0.41
10 0.12
-------------------------
#Newest scores appended
I would like to see user score changes. Each time a user gets a new score, we append it horizontally. Every-time we get a new user, we append it vertically. Assuming a user can only get 1 score per day, the ideal solution is:
visitorID score1 score2 score3
1 0.15 0.31
2 0.78 0.22 0.41
3 0.12
E.g. a table that grows horizontally (new scores) AND vertically (new users)
I can do something similar using a sequence of Left Joins on individual tables, but this would only give me the visitor data from 1st table we run left joins from.
Note: I can add another column
Date
which will simply repeat the same date for all values, if it makes things easier.