I defined a query that will become a view, where I extract amounts from a set of tables (expences) UNION ALL amounts from another set of tables (incomes).
Well, amounts from the query before UNION are extracted with decimals, as expected, whilst amounts from the query after UNION are integer.
I tried inverting the queries (incomes UNION expences) and this time incomes were with decimals, whilst amounts were integer.
In practice: the amount extracted from the query after UNION are alway integer! Why? And how can I get decimals, instead?
I discovered the reason: in the first query I extracted value ‘0’ for a field that have values different from 0 (with decimals) in the second query:
select field1, field2, 0 from …
UNION ALL
select field1, 0, field3 from…
Doing like this, by default the format was intended and managed as integer.
Instead,by selecting 0.00 in the first query, the format is intended as decimal, and this works as expected. The first query drives all the following.
select field1, field2, 0.00 from …
UNION ALL
select field1, 0.00, field3 from …
1 Like
Thank you for sharing your own solution.