Subject | Select Count(*) strange Result |
---|---|
Author | Dieter Tremel |
Post date | 2002-12-17T11:04:43Z |
Hallo ib-support,
at the first glance, Firebird 1.0 has as strange result from a
count(*) Statement:
The following sql fetches exactly 1 row as expected:
select
WBG.VERKAUFSKONTO
, A.UMSATZSTEUERCODE
, Sum(BBZ.BRUTTOBETRAG) as BRUTTOBET
, Sum(BBZ.NETTOBETRAG) as NETTOBET
, Sum(BBZ.MWSTBETRAG) as MWSTBET
FROM BBELEGZEILEN BBZ
JOIN ARTIKEL A on (BBZ.ARTIKELNR=A.ARTIKELNR)
JOIN WARENBUCHUNGSGRUPPEN WBG on (A.BUCHUNGSGRUPPE=WBG.WARENBUCHUNGSGRUPPE)
where BELEGID=8
GROUP BY WBG.VERKAUFSKONTO, A.UMSATZSTEUERCODE
HAVING Sum(BBZ.NETTOBETRAG) > 0
But the corresponding counting select returns 16:
select count(*)
FROM BBELEGZEILEN BBZ
JOIN ARTIKEL A on (BBZ.ARTIKELNR=A.ARTIKELNR)
JOIN WARENBUCHUNGSGRUPPEN WBG on (A.BUCHUNGSGRUPPE=WBG.WARENBUCHUNGSGRUPPE)
where BELEGID=8
GROUP BY WBG.VERKAUFSKONTO, A.UMSATZSTEUERCODE
HAVING Sum(BBZ.NETTOBETRAG) > 0
Any explanation/help for me?
Dieter Tremel
at the first glance, Firebird 1.0 has as strange result from a
count(*) Statement:
The following sql fetches exactly 1 row as expected:
select
WBG.VERKAUFSKONTO
, A.UMSATZSTEUERCODE
, Sum(BBZ.BRUTTOBETRAG) as BRUTTOBET
, Sum(BBZ.NETTOBETRAG) as NETTOBET
, Sum(BBZ.MWSTBETRAG) as MWSTBET
FROM BBELEGZEILEN BBZ
JOIN ARTIKEL A on (BBZ.ARTIKELNR=A.ARTIKELNR)
JOIN WARENBUCHUNGSGRUPPEN WBG on (A.BUCHUNGSGRUPPE=WBG.WARENBUCHUNGSGRUPPE)
where BELEGID=8
GROUP BY WBG.VERKAUFSKONTO, A.UMSATZSTEUERCODE
HAVING Sum(BBZ.NETTOBETRAG) > 0
But the corresponding counting select returns 16:
select count(*)
FROM BBELEGZEILEN BBZ
JOIN ARTIKEL A on (BBZ.ARTIKELNR=A.ARTIKELNR)
JOIN WARENBUCHUNGSGRUPPEN WBG on (A.BUCHUNGSGRUPPE=WBG.WARENBUCHUNGSGRUPPE)
where BELEGID=8
GROUP BY WBG.VERKAUFSKONTO, A.UMSATZSTEUERCODE
HAVING Sum(BBZ.NETTOBETRAG) > 0
Any explanation/help for me?
Dieter Tremel