Mysql - get sum() result in another column I get user_point column's sum like

select sum(user_point) as user_total_point from users;


but I also want to use that sum result for new generated column like

select sum(user_point) as user_total_point, (user_total_point * 100) as hundred_times from users;


-

Error: Query 1 ERROR: Unknown column 'user_total_point' in 'field list'


How can i use user_total_point column's value for another colums?
If you want both values in the result, you can nest them as in:

select user_total_point, (user_total_point * 100) as hundred_times
from (
    select sum(user_point) as user_total_point
    from users
) as tmp;


Renaming ( as user_total_point ) happens last, so you can not reference that at the same level as you are defining it. The name does not exist yet when you reference it.