problem with alias column field
I have a question regarding the mysql SELECT statement. Is it possible to use an alias in the expression for another alias, for example:
SELECT net,
tax_rate,
net / tax_rate AS tax,
net + tax AS gross
FROM items
But that dosent work, mysql dosent allow an alias in the SELECT statement (says it cant find a field called tax), which is kind of annoying as it means i have to duplicate all my calculations like this:
SELECT net,
tax_rate,
net / tax_rate AS tax,
net + (net / tax_rate) AS gross
FROM items
This might not seem like a big deal in this query, but i have some other far more complicated queries where its just a pain. Is there any way to do this, it seems like it should be possible.
Thanks.
Subject
Views
Written By
Posted
problem with alias column field
11084
April 06, 2008 10:21PM
3795
April 07, 2008 12:16AM
3637
April 07, 2008 07:48PM
Sorry, you can't reply to this topic. It has been closed.
Content reproduced on this site is the property of the respective copyright holders.
It is not reviewed in advance by Oracle and does not necessarily represent the opinion
of Oracle or any other party.