Example SQL using RDB$ tables to be reproducable on any database.
As you can see, the column type of douple precision * 1.00 can be determined.
But the column (number 3) of type of smallint * 1.00 can't and needs casting to be able to run. The same applies for numerics and (small)ints for example.
avg(i.RDB$STATISTICS * 1.00),
avg(i.RDB$FIELD_POSITION * 1.00),
cast(avg(i.RDB$FIELD_POSITION * 1.00) as decimal(9,2))