RicardoPereira
Programmer
I must convert "units" in "boxes" using one single query.
Here is an example,
I have this information in the database:
Box1 | Box2 | Box3 | Box4 | Units
=================================
10 2 0 10 12
0 0 0 10 225
0 3 0 10 6
0 0 5 10 24
The boxes here are in units. I must convert the Units in boxes.
The first line means that the Box1 has 10 units, Box2 has 2 units, Box3 has 0 units and the Box4 has 10 units.
What i need to produce is the equivalence in boxes using the Total units.
I must convert the Units in Boxes from the left to the rigth (Box1 to Box4).
This means that i will got:
Box1 | Box2 | Box3 | Box4 | Unit
=================================
1 1 0 0 0
0 0 0 0 225
0 2 0 0 0
0 0 4 0 1
The first line means that the 12 units that i have were equivalent to 1,2 boxes of type Box1 [(12/10)=1,2]. That means the it is 1 complete Box1. Next step is the remaining 0,2
0,2*10=2 (the 10 is from the Box1 to convert again to units)
Now i must convert this 2 in the next level (Box2) ... [(2/1)=2] ... this ends here because it is an integer. If i got an decimal value, i should convert the decimal to an integer an the remaining shoulbe be converted to Box3 ...
The remaining, in the end, after the convertion from the Box1 to Box4 are defined as Units
Anyone could helme with this?
Thanks,
Ricardo
Here is an example,
I have this information in the database:
Box1 | Box2 | Box3 | Box4 | Units
=================================
10 2 0 10 12
0 0 0 10 225
0 3 0 10 6
0 0 5 10 24
The boxes here are in units. I must convert the Units in boxes.
The first line means that the Box1 has 10 units, Box2 has 2 units, Box3 has 0 units and the Box4 has 10 units.
What i need to produce is the equivalence in boxes using the Total units.
I must convert the Units in Boxes from the left to the rigth (Box1 to Box4).
This means that i will got:
Box1 | Box2 | Box3 | Box4 | Unit
=================================
1 1 0 0 0
0 0 0 0 225
0 2 0 0 0
0 0 4 0 1
The first line means that the 12 units that i have were equivalent to 1,2 boxes of type Box1 [(12/10)=1,2]. That means the it is 1 complete Box1. Next step is the remaining 0,2
0,2*10=2 (the 10 is from the Box1 to convert again to units)
Now i must convert this 2 in the next level (Box2) ... [(2/1)=2] ... this ends here because it is an integer. If i got an decimal value, i should convert the decimal to an integer an the remaining shoulbe be converted to Box3 ...
The remaining, in the end, after the convertion from the Box1 to Box4 are defined as Units
Anyone could helme with this?
Thanks,
Ricardo