Skip to content

Instantly share code, notes, and snippets.

@konosp
Created November 8, 2019 09:54
Show Gist options
  • Select an option

  • Save konosp/c95e0b19b8463d5470f9a6e71365295e to your computer and use it in GitHub Desktop.

Select an option

Save konosp/c95e0b19b8463d5470f9a6e71365295e to your computer and use it in GitHub Desktop.
-- This query is not valid as there is no realtime data available in the sample data set.
CREATE VIEW
`project.dataset.ga_realtime_view` AS
SELECT
PARSE_DATE('%y%m%d',
_TABLE_SUFFIX) AS suffix,
visitKey AS visitKey2,
ARRAY_AGG(t
ORDER BY
exportTimeUsec DESC
LIMIT
1)[
OFFSET
(0)].*
FROM
`project.dataset.ga_realtime_sessions_20*` AS t
GROUP BY
suffix,
visitKey2
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment