我将两个查询传递给别名列inn
,out
我想这样做,
res=(inn-out)
但它给了我一个错误
Invalid column name 'inn'.
Invalid column name 'out'.
?
select productname
,inn=isnull((select sum(orderqty)
from purchasing.purchaseinvoicedetail
where productfk=Production.product.productid ),0)
,outt=isnull((select sum(orderqty)
from sales.salesinvoicedetail
where productfk=Production.product.productid ),0)
,res=(inn-outt)
from production.product