MySQL grouping by a previously declared alias, what do I wrap it in? ' OR `
- by cgmojoco
I have an SQL query that has an alias in the SELECT statement
SELECT
CONCAT(YEAR(r.Date),_utf8'-',_utf8'Q',QUARTER(r.Date)) AS 'QuarterYear'
Later, I want to refer to this in my group by statement.
I'm a little confused...should I wrap this with backticks, single quote or just leave it unwrapped int he group by
GROUP BY
`QuarterYear `
or should I do this?:
GROUP BY
'QuarterYear'
or just this?:
GROUP BY
QuarterYear