Pivot in SQL Big Query

PHOTO EMBED

Sun Aug 22 2021 17:21:44 GMT+0000 (UTC)

Saved by @jmbenedetto #sql

SELECT DISTINCT * FROM
    (SELECT
    user_id,
    group_id,
    REPLACE(LEFT(started_at,10),"-","") as started_at,
    FROM
    `analytics-dev-308300.dtm_engagement.ft_content_consumption`)
PIVOT
(COUNT(*) as s
for started_at in (list_of_values))
content_copyCOPY

List of values must be calculated before. It cannot be a select.