Am 01.02.24 um 07:51 schrieb LacaK via lazarus:
Hi,

IMO AVG() should produce floating point result.

https://www.sqlite.org/lang_aggfunc.html#aggfunclist: The result of
avg() is always a floating point value whenever there is at least one
non-NULL input even if all inputs are integers.

In SQLite plays role column affinity. I expect that "km_gelaufen" is
of NUMERIC or REAL affinity.

What result (in TDBGrid) gives: SELECT CAST(AVG(km_gelaufen)  AS REAL)
FROM laufdaten ?

L.


Ok, *solution* is to CAST AS Varchar the result:

SELECT CAST(AVG(km_gelaufen)  AS VARCHAR) FROM laufdaten

But  i don't understand why i do have to cast the result ...





In my SQlite Database laufdaten.db column "km_gelaufen"  is of Type
float. But SQlite does not know this type and if i understood that
correct SQLite  creates this type as needed?!

If i execute: "SELECT CAST(AVG(km_gelaufen) *AS REAL*) FROM laufdaten"
the known problem of integer only shows up again.

BUT:

If i execute this "SELECT CAST(AVG(km_gelaufen)  AS REAL) FROM laufdaten
" in SQliteStudio it works as it should.

Is DBgrid or Zeos Access components  the culpit? I don't know.

But  for me at the moment its ok now because i know how to circumvent
this problem with CAST() as VARCHAR

-- 
_______________________________________________
lazarus mailing list
lazarus@lists.lazarus-ide.org
https://lists.lazarus-ide.org/listinfo/lazarus

Reply via email to