I have a BigQuery table that is essentially an event trace for a given user session. I would like to partition the data by track in the example and produce a frequency distribution of events averaged over tracks.
track Event Name 1 A 1 B 1 C 2 A 3 A 3 B
So for these data the result would be
A - 100% B - 66% C - 33%
Which is to say all tracks contain event A, 66% of tracks contain event B and 33% of tracks contain event C.
I'd like to do this with analytic functions in SQL and PARTITION BY but am unsure how to proceed. Thanks!