Jump to content
Henry Olive

ClientDataSet Wrong Aggregate

Recommended Posts

Good Day

 

Delphi 10,4

 

Table Field Values :

(F1 = 95.615,79 ,  F2 = 6)

 

In Firebird SQL i make a calculation like ( F1 * F2 ) as TOTAL  and

in my query result (In Delphi)  = 573.694,74 which is correct

I have an Aggregate Field in my CDS and it's Expression = SUM(TOTAL)

In my table there is just 1 record and  the Aggregate result = 573.694,73

What am i doing wrong ?

 

Thank You

 

 

 

 

Share this post


Link to post

How are your DataSet fields and Aggregate Field declared ?

I think it's a rounding problem.

Share this post


Link to post

Thank you Serge, Happy new year

 

Price : Numeric(15,5)

Qty   : Numeric(15,2)

 

Firebird,:  Select  Sum(Price * Qty) as Total  (the result =  573.694,74 )

In Delphi I Created an Aggr.Field and its Expression is  Sum(Total)  (the result =  573.694,73 )

 

Thank You

 

Share this post


Link to post

Try a 

 

Select  Sum(Round(Price * Qty, 2)) as Total 

 

or

 

Select  Round(Sum(Price * Qty), 2) as Total 

 

 

And what is the FieldType in ClientdataSet?

 

Share this post


Link to post

Thank you Olli73, Happy New Year

 

Both Qty & Price fields are  TFMTBCDField;

Select  Sum(Round(Price * Qty, 2)) as Total  gives correct result

Share this post


Link to post

Create an account or sign in to comment

You need to be a member in order to leave a comment

Create an account

Sign up for a new account in our community. It's easy!

Register a new account

Sign in

Already have an account? Sign in here.

Sign In Now

×