The from
clause in your query starts:
FROM BDCComponentAttributes Left join
BDCComponentAttributes BDC10
on BDC10.ComponentID = BDCComponentAttributes.componentID and
BDC10.ComponentAttributeName = 'QuantityWH' Left join
OrderDetails
on OrderDetails.ConfigurationID = T3.ConfigIDx
When a query is compiled, the from
clause is interpreted in lexical ordering -- that is, in the same "left-to-right" "top-to-bottom" way that we read. When the symbol T3
is encountered, it is not defined. That is causing your error. SQL does not have "look-ahead" to see that it is defined later in the from
clause.
You can fix this by moving the join
condition after the definition of T3
.