Ask Your Question
0

How to force float - LO Base

asked 2020-11-21 14:20:37 +0100

KopfSzmercen gravatar image

updated 2020-11-21 14:21:04 +0100

Hi, I have a problem- I can't force my AVG to have floating point. From what I know the AVG() function should in itself give me a number with floating point. I tried using CAST( AVG(column) as FLOAT) but still, it doesn't help. Could anyone tell me what is wrong, or maybe I'm making a mistake. Cheers!

edit retag flag offensive close merge delete

Comments

May be the answer depends on the database you are using (firebird, HSQLDB, or any external DB) For Firebird: Result type: A numeric data type, the same as the data type of the argument what would let me ask: What is the data type of the data you want the AVG() build from? If it is an integer value, the result from my interpretation of the documentation would be: AVG() gives an integer as well (Firebird only - just to make an example that your assumption the AVG() function should in itself give me a number with floating point may be wrong at least for one database).

Opaque gravatar imageOpaque ( 2020-11-21 15:01:06 +0100 )edit

Man, you saved my life :) I followed up your suggestion- I created my main table once more, but instead of setting the data type to INT I set it to FLOAT. Now, when I'm using AVG(), the result is as it should be. Thanks.

KopfSzmercen gravatar imageKopfSzmercen ( 2020-11-21 16:26:20 +0100 )edit

There is no need to close a question but it is highly welcome, if you click the check mark (✔) next to the answer, which helped you. This is the indicator on this site for "working solution for a question can be found here"

Opaque gravatar imageOpaque ( 2020-11-21 16:52:22 +0100 )edit

1 Answer

Sort by » oldest newest most voted
1

answered 2020-11-21 16:49:49 +0100

Opaque gravatar image

For the records:

Set the data type of the data to be averaged to the type you want to get by AVG() (i.e. here: to floating point).

edit flag offensive delete link more
Login/Signup to Answer

Question Tools

1 follower

Stats

Asked: 2020-11-21 14:20:37 +0100

Seen: 24 times

Last updated: Nov 21