I have a query:
SELECT
...
(some expression) AS Country
FROM
Sometable
...
GROUP BY Country;
Sometablehas a column namedCountry(this can’t be changed).- One of the result columns is named
Country(this can’t be changed either).
It works (I want the GROUP BY to apply on the result column, and this is the way MySQL understands it as well).
But it issues a warning:
Warning: Column 'Country' in group statement is ambiguous
So, I want to disambiguate the GROUP BY. But the only qualifiers I could find are to specify the database or the table (as in: Sometable.Country). It would be fine if the label was used in two different tables, of if I wanted to choose the instance of the label which comes from a table. But I need some kind of Select.Country qualifier to specify that the name I want to use is the one from the SELECT clause, not the one from the table.
I find it a bit strange that this warning can be removed if I want to select one of the 2 instances of the label (the column of the table), but not if I want to select the other one (the column of the result).
1 Answer