简体   繁体   English

SQL不等于0.00十进制值

[英]SQL does not equal 0.00 decimal value

I am trying to make a SQL call that avoids orders with Subtotal of $0. 我正在尝试进行SQL调用,以避免小计为$ 0的订单。 I can't get it to omit orders that have a Subtotal of 0.00. 我无法忽略小计为0.00的订单。

My SQL call: 我的SQL调用:

SELECT Orders_Products.productID, 
       Orders_Products.QtyOrdered,
       Orders.DateCreated, 
       Orders_Products.Subtotal, 
       SUM(Orders_Products.Subtotal) as Revenue 
FROM `Orders_Products` 
INNER JOIN Orders 
ON Orders_Products.OrderID = Orders.OrderID 
WHERE ProductID <= 21 
    AND ProductID >= 19 
    OR ProductID = 41 
    AND Orders_Products.Subtotal <> 0.00 
    AND MONTH(Orders.DateCreated) = MONTH(CURDATE()) 
    AND Year(Orders.DateCreated) = YEAR(CURDATE()) 
GROUP BY DateCreated 
ORDER BY `Orders`.`DateCreated` DESC

This is where I'm having the issue (still shows orders with Subtotal 0.00): 这是我遇到的问题(仍然显示小计0.00的订单):

AND Orders_Products.Subtotal <> 0.00

I've also tried 我也尝试过

AND Orders_Products.Subtotal != 0.00
AND Orders_Products.Subtotal <> 0
AND Orders_Products.Subtotal <> "0.00"

But my output still includes line items with Subtotal 0.00: 但是我的输出仍然包括总计为0.00的订单项:

在此处输入图片说明

I guess there is something wrong with brackets. 我想方括号有问题。 It looks like it should be gathered as one condition: 看起来应该将其作为一种条件收集:

(ProductID <= 21 AND ProductID >= 19 OR ProductID = 41)

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM