简体   繁体   English

如果Sum = 0,则从结果中排除

[英]Exclude from result if Sum = 0

How to exclude records from the result if (+)LotQty has the same with (-)LotQty but different Transtype . 如果(+)LotQty(-)LotQty相同但Transtype不同,如何从结果中排除记录。

Example : from this 例子:从这里

Docentry  Transtype  LotQty
4594      67          250.000000
4643      60         -250.000000
9253      67          100.000000
16822     60         -200.000000

to this 对此

Docentry  Transtype  LotQty
9253      67         100.000000
16822     60        -200.000000**

Im not sure on the Group by part because of the aggregate but, you can try this: 由于汇总,我不能确定该分组的一部分,但是,您可以尝试以下操作:

 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.

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