CAST(SaleQty AS INT)-CAST(ISNULL( Qty,0) AS INT) CountQty select ISNULL( CAST(E.Qty AS INT),0 ) FROM OrderDetail E 空值 須要默認爲0 便可