In Access, when you write a query having a field that calculates values you can refer to that same field by its name elsewhere in the query without having to repeat the calculation.
For example, in the query below, in order to calculate the Taxable Amount, I can refer to the "Total" field within the same query...
SELECT Qty, Price, (Qty * Price) AS Total, (Total * Tax) AS TaxAmount
FROM tblSalesOrder
Within SQL Server I must recalculate the Total within the TaxAmount calculation, rather than simply referring to the Total field...
SELECT Qty, Price, (Qty * Price) AS Total, (Qty * Price * Tax) AS TaxAmount
FROM tblSalesOrder
Is there any simple way around this limitation so that I can include multiple calculation within the same query/view? The query I'm writing is very large and complex with over 150 fields and many of the figures rely on previously calculated fields. Having to repeat initial calculations to be used in subsequent calculations just seems counterproductive and makes the query very difficult to interpret.
I know I can create a view that does the initial calculations and then nest that view in a subsequent view, but to accomplish this I might require 4 or 5 levels of nesting...again, counterproductive.
TIA,
Rick
For example, in the query below, in order to calculate the Taxable Amount, I can refer to the "Total" field within the same query...
SELECT Qty, Price, (Qty * Price) AS Total, (Total * Tax) AS TaxAmount
FROM tblSalesOrder
Within SQL Server I must recalculate the Total within the TaxAmount calculation, rather than simply referring to the Total field...
SELECT Qty, Price, (Qty * Price) AS Total, (Qty * Price * Tax) AS TaxAmount
FROM tblSalesOrder
Is there any simple way around this limitation so that I can include multiple calculation within the same query/view? The query I'm writing is very large and complex with over 150 fields and many of the figures rely on previously calculated fields. Having to repeat initial calculations to be used in subsequent calculations just seems counterproductive and makes the query very difficult to interpret.
I know I can create a view that does the initial calculations and then nest that view in a subsequent view, but to accomplish this I might require 4 or 5 levels of nesting...again, counterproductive.
TIA,
Rick