Subject Re: casting to decimal(9,2) gives different answers if used with a group by clause
Author wibbleian2
--- In firebird-support@yahoogroups.com, Svein Erling Tysvær <svein.erling.tysvaer@...> wrote:
>
> The dogdy thing about it, is that you seem to treat the symptoms, not the cause.
>
The dodgy thing about it is that I get 2 different answers depending on the accident of the sql statement.

I agree that this is not treating the cause, but I can't figure out an alternative that really fits my needs. Especially not one that is just based on dabbling with data types.

I have a better fix for this specific "symptom" but I'm not convinced I'm being unreasonable expecting the same answer from the example queries given the sample data.

> select cast(sum(qty) as decimal(9,2)) from tmp;
130.28

> select parent_id, cast(sum(qty) as decimal(9,2)) from tmp group by
parent_id;
130.27

(If there were more "parent_id" groups in there then this is obviously going to give me different numbers, but that's not really what the example was showing)

I do, however, take the point that anything I do from here is simply fixing the symptom, but that's all I've got to play with....

Thanks for the answers, at least I know I've not gone completely mad.

Ian