group by alias
Posted: Thu 13 Feb 2014 21:29
Hi I have a simple query as below, when I go to the group by tab it shows the alias as selectable but when I select it, it shows as a numeric value. Am I doing something wrong here?
Thanks in advance.

SELECT
`billing_data`.`start_gmt_datetime` AS `start_gmt_datetime`,
MONTHNAME(start_gmt_datetime) AS `month`,
YEAR(start_gmt_datetime) AS `year`,
sum(kwh_used) AS `month_total`
FROM `billing_data`
WHERE `member_account_no` = 'SE0033284'
GROUP BY `month`, `year`
ORDER BY `start_gmt_datetime` ASC
Thanks in advance.

SELECT
`billing_data`.`start_gmt_datetime` AS `start_gmt_datetime`,
MONTHNAME(start_gmt_datetime) AS `month`,
YEAR(start_gmt_datetime) AS `year`,
sum(kwh_used) AS `month_total`
FROM `billing_data`
WHERE `member_account_no` = 'SE0033284'
GROUP BY `month`, `year`
ORDER BY `start_gmt_datetime` ASC