我有一张桌子
我需要排除所有具有round( sum(QtyInvoiced),1) = 0 and round(sum(Amount),1) =0
我尝试了以下脚本,但是它不起作用,如何纠正?
select sum( QtyInvoiced ) , sum(Amount) ,salesNumber
from invoicesales
group by salesNumber
except
select sum( QtyInvoiced ) , sum(Amount) ,salesNumber
from invoicesales
group by salesNumber
having round( sum(QtyInvoiced),1) = 0 and round(sum(Amount),1) =0
答案 0 :(得分:3)
尝试使用<>不等于
,如下所示select sum( QtyInvoiced ) , sum(Amount) ,salesNumber
from invoicesales
group by salesNumber
having round( sum(QtyInvoiced),1) <> 0 and round(sum(Amount),1)<>0
答案 1 :(得分:2)
如果您要排除这些行,也许您想要NOT
?
HAVING NOT(ROUND( SUM(QtyInvoiced),1) = 0 AND ROUND(SUM(Amount),1) = 0);
否则,您的SQL将完全按照您的要求执行 ,以返回行QtyInvoiced
和 Amount
之和等于 0
(不排除那些相等的对象)。