Description:
i have table name test1
here is sample data inside this table
SELECT *
FROM `test1`
+---------+--------+---------+
| dat_1 | dat_2 | dat_3 |
+---------+--------+---------+
| 10.0000 | 4.5000 | 55.0000 |
| 13.0000 | 4.5000 | 31.0000 |
| 12.0000 | 3.7000 | 51.0000 |
| 10.0000 | 4.5000 | 55.0000 |
+---------+--------+---------+
but when execute this statement
set @c:=0,@d:=0;
SELECT *, @c:=1-(dat_3/100), @d:=dat_2/@c, @c:=dat_1-@d FROM test1;
+---------+--------+---------+-------------------+-----------------+-----------------------+
| dat_1 | dat_2 | dat_3 | @c:=1-(dat_3/100) | @d:=dat_2/@c | @c:=dat_1-@d |
+---------+--------+---------+-------------------+-----------------+-----------------------+
| 10.0000 | 4.5000 | 55.0000 | 0.450000 | 10 | -1.7763568394003e-015 |
| 13.0000 | 4.5000 | 31.0000 | 0.690000 | 6.5217391304348 | 6.4782608695652 |
| 12.0000 | 3.7000 | 51.0000 | 0.490000 | 7.5510204081633 | 4.4489795918367 |
| 10.0000 | 4.5000 | 55.0000 | 0.450000 | 10 | -1.7763568394003e-015 |
+---------+--------+---------+-------------------+-----------------+-----------------------+
i have try to run this statement on 4.0.16 to 4.0.20a, it return wierd result, hope someone can help me
thanks
How to repeat:
select @a:=10, @b:=4.5, @c:=1-(55/100),@d:=@b/@c, @c:=@a-@d
+--------+---------+----------------+-----------+-----------------------+
| @a:=10 | @b:=4.5 | @c:=1-(55/100) | @d:=@b/@c | @c:=@a-@d |
+--------+---------+----------------+-----------+-----------------------+
| 10 | 4.5 | 0.45 | 10 | -1.7763568394003e-015 |
+--------+---------+----------------+-----------+-----------------------+