SELECT --PartnerId,
ScheLineDesc,
PartNumber,
TotalQtyOrder,
TotalShippedQty,
TotalQtyOrder - TotalShippedQty AS TotalBalanceToShip
当TotalShippedQty为Null时,我需要在TotalBalanceToShip中显示TotalQtyOrder。现在,我只会得到Null。
答案 0 :(得分:2)
使用coalesce()
函数
select ScheLineDesc,
PartNumber,
TotalQtyOrder,
TotalShippedQty,
coalesce(TotalQtyOrder, 0) - coalesce(TotalShippedQty, 0) as TotalBalanceToShip
答案 1 :(得分:1)
您可以使用Isnull
或NVL
函数检查值并将其替换为null