12 Aug 18 · Bozhack-miller ·       Add to Favorites   Report

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

Read great educational content like this and a lot more !

Members get free exclusive access to content, new courses, and discounts. Signup for a free account to write a post / comment / upvote posts. Creating an account takes less than 5 seconds and you can start earning badges & points too

Copied