CAST(SaleQty AS INT)-CAST(ISNULL( Qty,0) AS INT) CountQty select ISNULL( CAST(E.Qty AS INT),0 ) FROM OrderDetail E 空值 须要默认为0 便可