crhuebner
03-16-2009, 06:41 PM
Hi, I am new to SQL and am curious about how to use derived columns in other calculations. For example I am trying to take a "Price" column from a table called "ord" and calculate sales tax and total price. I am currently using the following SQL statement, which works:
SELECT price AS Price, price*.06 AS "SalesTax", Price+(Price*.06) AS "Total Price"
[ ][ ]FROM ord;
I was wondering if there is a way to use the previously calculated "SalesTax" field to calculate "Total Price", instead of reusing the (Price*.06) again. What I would like to do is use (Price + SalesTax) to calculate "Total Price" instead of
(Price + Price*.06). Any help would be much appreciated. Thanks!
SELECT price AS Price, price*.06 AS "SalesTax", Price+(Price*.06) AS "Total Price"
[ ][ ]FROM ord;
I was wondering if there is a way to use the previously calculated "SalesTax" field to calculate "Total Price", instead of reusing the (Price*.06) again. What I would like to do is use (Price + SalesTax) to calculate "Total Price" instead of
(Price + Price*.06). Any help would be much appreciated. Thanks!