12 Aug 18 · Bozhack-miller ·       Add to Favorites  

BigQuery Error: SELECT list expression references column X which is neither grouped nor aggregated at Y

Problem: You will get this error when you use aggregate functions in the select clause and forgot to include those columns in the group by clause

Example: To fetch the highest salary from each office location

Query:

SELECT office_location, 
       MAX(salary) AS highest_salary
FROM table;

you will get this error: Error: SELECT list expression references column X which is neither grouped nor aggregated at [2:49]

Try doing this instead:

SELECT office_location, 
MAX(salary) AS highest_salary
FROM table GROUP BY office_location;

Should solve the issue

Bozhack-miller

posted on 12 Aug 18

Enjoy great content like this and a lot more !

Signup for a free account to write a post / comment / upvote posts. Its simple and takes less than 5 seconds

Copied