[英]Exclude from result if Sum = 0
如果(+)LotQty
与(-)LotQty
相同但Transtype
不同,如何从结果中排除记录。
例子:从这里
Docentry Transtype LotQty
4594 67 250.000000
4643 60 -250.000000
9253 67 100.000000
16822 60 -200.000000
对此
Docentry Transtype LotQty
9253 67 100.000000
16822 60 -200.000000**
由于汇总,我不能确定该分组的一部分,但是,您可以尝试以下操作:
SELECT A.Docentry, A.Transtype, A.LotQty
FROM your_table as A
WHERE A.ItemCode IN
(SELECT B.ItemCode
FROM your_table as B
WHERE SUM(B.LotQty) = 0
GROUP BY B.ItemCode)
您可以使用ABS函数获取绝对值并进行比较。
Select * from Table T1 join Table T2 Where ABS(T1.LotQty)<>ABS(T2.LotQty)
声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.