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!
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).
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.
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”
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).