我使用以下查询:
select Containers.SalesOrderNumber,
GetWeightInMT(Sum([NetWeight]), WeightUOM) as Expr1,
CInt(Round(GetWeightInMT(Sum([NetWeight]), WeightUOM), 0)) as WtMt,
SalesOrders.CustomerID,
SalesOrders.SalesOrderID,
SalesOrders.UnitPrice,
SalesOrders.Quantity,
SalesOrders.SalesCommission,
SalesOrders.LatestShipDate,
SalesOrders.PortOfDischarge,
SalesOrders.PlaceOfDelivery,
SalesOrders.LowerTolerancePct,
SalesOrders.UpperTolerancePct,
SalesOrders.Grade,
(SalesOrders.Quantity - WtMt) as OpenQty
from Containers
inner join SalesOrders on Containers.SalesOrderNumber = SalesOrders.SalesOrderNumber
group by Containers.SalesOrderNumber,
Containers.WeightUOM,
SalesOrders.CustomerID,
SalesOrders.SalesOrderID,
SalesOrders.UnitPrice,
SalesOrders.Quantity,
SalesOrders.SalesCommission,
SalesOrders.LatestShipDate,
SalesOrders.PortOfDischarge,
SalesOrders.PlaceOfDelivery,
SalesOrders.LowerTolerancePct,
SalesOrders.UpperTolerancePct,
SalesOrders.Grade;
然后计算" OpenQty"的总和在我的文本框中。 但是我得到错误"标准表达式中的数据类型不匹配"。 请帮忙。 三江源
答案 0 :(得分:0)
您不能将计算字段(在本例中为WtMt
)用作另一个字段计算的一部分。您必须重复使用整个计算。
(SalesOrders.Quantity - WtMt) as OpenQty
到
(SalesOrders.Quantity - CInt(Round(GetWeightInMT(Sum([NetWeight]), WeightUOM), 0))) as OpenQty
然而,这可能不是唯一的问题。我建议一次运行一个计算字段的查询,看看哪一个实际上给你错误。