我有以下SQL-Query:
SELECT
FGLEDG.EGCONO,
FGLEDG.EGDIVI,
FGLEDG.EGVONO,
SUM(FGLEDG.EGACAM) AS BOKFBEL,
MAX(FGLEDG.EGAIT1) AS KNT,
MAX (FGLEDG.EGVDSC) AS VERTYP
FROM SEUHATG2.M3PRD.FGLEDG FGLEDG
WHERE (FGLEDG.EGCONO = 001)
AND (FGLEDG.EGDIVI = '012')
AND (FGLEDG.EGAIT1 IN ('2448','6995','2480'))
GROUP BY FGLEDG.EGCONO, FGLEDG.EGDIVI, FGLEDG.EGVONO
HAVING SUM(FGLEDG.EGACAM) <> 0
它在结果中给出了下表:
EGCONO | EGDIVI | EGVONO | BOKFBEL | KNT | VERTYP
-----------------------------------------------------------
1 | 012 | 20100574 | -4120 | 2448 | MANFAK
1 | 012 | 20200488 | 2924,8 | 6995 | BOKFORD
1 | 012 | 20200701 | -10252 | 6995 | BOKFORD
1 | 012 | 20200758 | 1674,4 | 6995 | BOKFORD
1 | 012 | 20200792 | -899,2 | 2448 | BOKFORD
1 | 012 | 20200808 | -1694,4 | 6995 | BOKFORD
1 | 012 | 20200832 | -15724,8 | 6995 | BOKFORD
1 | 012 | 20200986 | -2798,4 | 2448 | BOKFORD
1 | 012 | 20201007 | -54180 | 6995 | BOKFORD
1 | 012 | 20201009 | -7154 | 6995 | BOKFORD
1 | 012 | 20201106 | -36928,8 | 6995 | BOKFORD
1 | 012 | 20202274 | -2639,36 | 2448 | BOKFORD
1 | 012 | 20202613 | -5359,26 | 2448 | BOKFORD
1 | 012 | 20203715 | 15816,22 | 2448 | BOKFORD
1 | 012 | 30205552 | -1095,5 | 2448 | BOKFORD
1 | 012 | 30206333 | -51,63 | 2448 | BOKFORD
1 | 012 | 30206334 | 60,73 | 2448 | BOKFORD
1 | 012 | 30206335 | -162,36 | 2448 | BOKFORD
1 | 012 | 30206473 | 121314,8 | 6995 | BOKFORD
1 | 012 | 40200314 | -48830 | 6995 | BOKFORD
1 | 012 | 40200915 | 48830 | 2448 | BOKFORD
1 | 012 | 40200925 | -400000 | 2448 | BOKFORD
1 | 012 | 40200926 | 400000 | 2448 | BOKFORD
1 | 012 | 40200947 | 4616,98 | 2448 | BOKFORD
1 | 012 | 40200948 | -4616,98 | 2448 | BOKFORD
1 | 012 | 40201257 | -2637868,75 | 6995 | BOKFORD
1 | 012 | 40201315 | 551000 | 2448 | BOKFORD
1 | 012 | 40201316 | -551000 | 2448 | BOKFORD
1 | 012 | 40201324 | 24393 | 2448 | BOKFORD
1 | 012 | 40201325 | -24393 | 2448 | BOKFORD
1 | 012 | 40201342 | 2817000 | 2448 | BOKFORD
1 | 012 | 40201343 | -2817000 | 2448 | BOKFORD
1 | 012 | 40201409 | 2637868,75 | 6995 | BOKFORD
我希望我的查询也排除金额等于零的行,即使EGVONO没有相同的值也是如此。 (例如,EGVONO 40200314和40200915等于零,如果一个广告他们的金额。)
我该怎么做?并且Query是否可以首先获得上面的结果,然后采取额外的循环并进行排除?