Skip to content

Instantly share code, notes, and snippets.

@ddikman
Created September 27, 2021 14:23
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save ddikman/f82154a18719eb399e8591bba987e686 to your computer and use it in GitHub Desktop.
Save ddikman/f82154a18719eb399e8591bba987e686 to your computer and use it in GitHub Desktop.
Getting average order price per platform
select
platform,
avg(p.value.double_value) as avg_value,
count(distinct(user_pseudo_id)) as views,
DATE_TRUNC(DATETIME(TIMESTAMP_MICROS(event_timestamp)), MONTH) as month
FROM `<project>.analytics_<id>.events_*`,
unnest(event_params) p
where event_name = 'view_item' and p.key = 'value'
group by month, platform
order by month, platform
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment