首页 > 代码库 > sql中sum默认值为0的函数是COALESCE

sql中sum默认值为0的函数是COALESCE

SELECT COALESCE(SUM((price/priceper)*QtyRequired),0) as total_value,       COALESCE(SUM((price/priceper)*QtyRequired),0) as outstanding_valueFROM @Item iLEFT OUTER JOIN @OrderItem o ON i.Id = o.ItemIdWHERE i.Id = @ItemIdTestgroup by itemId

sql中sum默认值为0的函数是COALESCE