column aliases should take precedence over columns in underlying table

column aliases should take precedence over columns in underlying table

When I do this query:
SELECT
  IF( landing_niche IS NOT NULL, landing_niche, 'none' ) AS niche,
  months.month AS month,
  COUNT( sites.id ) AS sites_count
FROM 
  months,
  sites
WHERE
  sites.inserted_at >= months.month
GROUP BY niche, month

It groups on the values in the "niche" field in the sites table, instead of the value of the aliased column "niche" in the select query.

The alias should have priority over the fields in the table.  Or actually, perhaps you just shouldn't be able to group on a field that is not present in the list of columns in the query.