[英]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.