如下代码:

 SELECT ISNULL(sum(Product.Price*ShoppingCart.Quantity),0)
 From ShoppingCart INNER JOIN Product
 ON ShoppingCart.ProductID=Product.ProductID
  WHERE ShoppingCart.CartID=@CartID

使用ISNULL方法目的是,当总价的值为NULL时,将其转成0.由于业务层预期将收到一个表示总价的数字值,因此必须这么做。

相关文章:

  • 2022-03-05
  • 2022-12-23
  • 2022-12-23
  • 2021-11-23
  • 2021-07-17
  • 2021-11-23
  • 2021-12-02
猜你喜欢
  • 2021-11-23
  • 2021-11-23
  • 2021-09-02
  • 2022-12-23
  • 2021-11-23
  • 2021-08-18
  • 2021-11-23
相关资源
相似解决方案