I'm trying to create a new field based in another (sum field)
SELECT sum(price) AS old_price, old_price+100 AS total_price FROM sales
This returns Unknown column 'old_price' in 'field list'
sum is just a example, my real issue is to use with a select inside this field
What am I doing wrong?
--edit I've used variables to reuse the alias, updated code:
SELECT @old_price := sum(price) AS old_price, @old_price+100 AS total_price FROM sales
If you think that it is not a good practice, tell me.