Using Big Query, I am trying to query
count(distinct col), count (distinct col) over (partition by col2)
But I receive an unexpected error.
Here is the template of the query i'm trying to execute:
SELECT
country,
partner,
segment_id,
COUNT(DISTINCT pv_id) pvs,
COUNT(DISTINCT pv_id) over(PARTITION BY country) country_total_pvs
FROM (...)
GROUP BY
country,
partner,
segment_id
And the error I keep getting:
Error: Expression 'pv_id' is not present in the GROUP BY list
Without the 5th column (the analytical count), the query executes without any error.
Thoughts?
Many Thanks!
SELECT language, title, COUNT(DISTINCT contirbutor_username), COUNT(DISTINCT contirbutor_username) over( PARTITION BY language) FROM [bigquery-public-data:samples.wikipedia] GROUP BY language, title
what I really want to have is grouping result of different dimensions. – goidelg