I’ve been getting this error when doing what I thought to be one of the simplest possible queries! I see other people have run into issues here too, and I’ve looked through every solution I’ve seen but they’re with more involved queries so it was very hard for me to pick out the problem. I made a little dummy table to illustrate my problem.
table name: grouptest
id name
1 Mel
2 Lucy
3 Mandy
4 Mel
5 Mandy
6 Mel
I want to find out how many times each name shows up, to produce a table like:
3 Mel
2 Mandy
1 Lucy
Here’s the query I think should work:
SELECT Count(id), Name
FROM groupbytest
GROUP BY 'Name'
And I get the error:
Each GROUP BY expression must contain at least one column that is not
an outer reference.
Help!
You have quotes around the Name field which are unneeded.
Based on your comments, you need to
CASTyourNamecolumn: