Subject Re: [firebird-support] "HAVING" Bug
Author Alexandre Benson Smith
Leyne, Sean wrote:
> Michael,
>
>
>> The following query returns all records including those with
>> a zero sum(glt_total) the HAVING should be discarding them:
>>
>> select glt_group, sum(glt_total)
>> from gltrans
>> where glt_actperiod >= 200801
>> group by glt_group
>> having sum(glt_total) <> 0
>> order by 2
>>
>>
>> Also, it appears that if I change to <> to < then it will
>> return records that are less than zero and equal to zero.
>>
>> If I change to <> to > then it will return records that are
>> greater than zero and equal to zero.
>>
>
> What is the datatype of the glt_total column?
>
> I suspect that the problem is that the glt_total has values that are not
> truly zero -- your application is showing you zero when the database has
> a value like 0.0000012313123.
>
> Replace the HAVING clause with "having ABS(sum(glt_total)) <> 0"
>
>
> Sean
>

Shoudn't it be:

Replace the HAVING clause with "having ABS(sum(glt_total)) < 0.0001"

or something like this ?



--
Alexandre Benson Smith
Development
THOR Software e Comercial Ltda
Santo Andre - Sao Paulo - Brazil
www.thorsoftware.com.br