Here the division between td1.c1 and td2.c2 is correct:
select td1.c1, td2.c2, td1.c1/td2.c2, -99 / 0.03 from testdata td1, testdata td2 where td1.c1 = -99 and td2.c2 = 0.03 limit 1; +------+------+---------------+------------+ | c1 | c2 | td1.c1/td2.c2 | -99 / 0.03 | +------+------+---------------+------------+ | -99 | 0.03 | -3300.0000 | -3300.0000 | +------+------+---------------+------------+ 1 row in set (0.00 sec) Here DISTINCT is added to the query. The result is incorrect: select distinct td1.c1, td2.c2, td1.c1/td2.c2, -99 / 0.03 from testdata td1, testdata td2 where td1.c1 = -99 and td2.c2 = 0.03 limit 1; +------+------+---------------+------------+ | c1 | c2 | td1.c1/td2.c2 | -99 / 0.03 | +------+------+---------------+------------+ | -99 | 0.03 | -999.9999 | -3300.0000 | +------+------+---------------+------------+ 1 row in set (0.00 sec)
…