In MySQL, I can do the following query:
select first_name from `table` group by age
However, if I do something similar in BigQuery, I get the following error:
SELECT list expression references column first_name which is neither grouped nor aggregated
How would we write the equivalent mysql aggregation query in BigQuery?
In BigQuery, you should be using window functions:
This works in MySQL 8+ as well.
you have to put all the selected column in
group by
alsobtw before 8.0 version of mysql it was allow but from 8.0 it is not allow
but in you query there is no aggregate function so you can use distinct rather than group by
Below is for BigQuery Standard SQL and as simple as below
As you can see you were missing just aggregation function - it can be any - MAX, MIN, etc. I've chosen ANY_VALUE as an example
You can test, play with above using some simplified dummy data like in example below
with result