The results I get when querying a database are rounded to two decimal places. How can I get dbase to return results rounded to 8 decimal places?
There needs to be the number of decimals in one of the fields used in the calculation for the result to contain the number of decimals you desire. That’s a lot in one sentence so here is an example.
First make sure Run SQL command directly
is selected on toolbar (SQL icon). Without it on, the interpreter will generate different results.
Let’s use a field (“MYID”) which is a 10 digit Integer with no decimal positions. Let’s say the field has a value of “1”. If you divide “MYID” by “1732” the result will be “0”. There are no decimal places defined. If, however you divide “MYID” by"1732.00000000" the result is “0.00057736”.
If just using fields in the calculation ( i.e. “MYNUMBER” = 1732) then you can change the number of decimals with cast
.
Select cast(MYID as NUMERIC(10,8)) / MYNUMBER as RESULT from MYTABLE
will give the same result of “0.00057736” since “MYID” was set to eight decimal positions.
This is just one particular example and can have many variations.