I have a mysql query that looks something like this:
SELECT
SUM(reg_yr) AS reg_yr_total,
SUM(spot_as_reg_yr) AS spot_as_reg_yr_total
FROM foo
WHERE bar
GROUP BY baz
ORDER BY reg_yr_total
which works just fine. if I want to change the ORDER BY clause to be reg_yr_total+spot_as_reg_yr_total
however, I get an error stating Reference 'reg_yr_total' not supported (reference to group function)
.
Why can I use each of these columns by themselves, but as soon as I try to add the two together it fails? Is there a way around this?