I have a problem!
When running a statement, which will select a field which is calculated by three INTEGER fields, the result will be INTEGER, too.
expl1:
select a.int1*a.int2/a.int3 as res from a
I need the field as an decimal (18,2).
I tried it twice
expl2:
select cast((a.int1*a.int2/a.int3)as decimal (18,2)) as res from a
expl3:
select cast(a.int1 as decimal (18,2))*a.int2/a.int3 as res from a
Both times the resultfield res changed its type into decimal (18,2). But it was multiplicated by 100.
So when the operation was like 10*2/8 then
expl 1 result: 10*2/8=2 (TYPE INTEGER).
expl 2 result: 10*2/8=250,00 (TYPE DECIMAL (18,2))
expl 3 result: 10*2/8=250,00 (TYPE DECIMAL (18,2))
Now i thought it to be a good idea to divide the result by 100. But the new result was as the following:
expl4:
select cast((a.int1*a.int2/a.int3)as decimal (18,2))/100 as res from a
expl 4 result: 10*2/8=2,00 (TYPE DECIMAL (18,2))
Can someone tell me, how I make the system answer
10*2/8=2,50 (TYPE DECIMAL (18,2))
Thank you for your help
When running a statement, which will select a field which is calculated by three INTEGER fields, the result will be INTEGER, too.
expl1:
select a.int1*a.int2/a.int3 as res from a
I need the field as an decimal (18,2).
I tried it twice
expl2:
select cast((a.int1*a.int2/a.int3)as decimal (18,2)) as res from a
expl3:
select cast(a.int1 as decimal (18,2))*a.int2/a.int3 as res from a
Both times the resultfield res changed its type into decimal (18,2). But it was multiplicated by 100.
So when the operation was like 10*2/8 then
expl 1 result: 10*2/8=2 (TYPE INTEGER).
expl 2 result: 10*2/8=250,00 (TYPE DECIMAL (18,2))
expl 3 result: 10*2/8=250,00 (TYPE DECIMAL (18,2))
Now i thought it to be a good idea to divide the result by 100. But the new result was as the following:
expl4:
select cast((a.int1*a.int2/a.int3)as decimal (18,2))/100 as res from a
expl 4 result: 10*2/8=2,00 (TYPE DECIMAL (18,2))
Can someone tell me, how I make the system answer
10*2/8=2,50 (TYPE DECIMAL (18,2))
Thank you for your help