Description:
mysql> select ELT(LEAST(6, FLOOR((NULL + 4) / 7)), '$6.00 a month for 12 months', '$12.00 every other month for 12 months', '$18.00 every 3 months for 12 months', '$24.00 every 4 months for 12 months', '$36.00 twice a year for 1 year', '$72.00 paid in full') AS Plan;
+---------------------+
| Plan |
+---------------------+
| $72.00 paid in full |
+---------------------+
1 row in set (0.00 sec)
mysql> select LEAST(6, FLOOR((NULL + 4) / 7));
+---------------------------------+
| LEAST(6, FLOOR((NULL + 4) / 7)) |
+---------------------------------+
| NULL |
+---------------------------------+
1 row in set (0.00 sec)
mysql> select ELT((NULL + 4) / 7, '$6.00 a month for 12 months', '$12.00 every other month for 12 months', '$18.00 every 3 months for 12 months', '$24.00 every 4 months for 12 months', '$36.00 twice a year for 1 year', '$72.00 paid in full') AS Plan;
+------+
| Plan |
+------+
| NULL |
+------+
1 row in set (0.00 sec)
mysql> select @@version;
+-----------+
| @@version |
+-----------+
| 5.5.8-log |
+-----------+
1 row in set (0.00 sec)
mysql> select ELT(FLOOR((NULL + 4) / 7), '$6.00 a month for 12 months', '$12.00 every other month for 12 months', '$18.00 every 3 months for 12 months', '$24.00 every 4 months for 12 months', '$36.00 twice a year for 1 year', '$72.00 paid in full') AS Plan;
+------+
| Plan |
+------+
| NULL |
+------+
1 row in set (0.00 sec)
How to repeat:
as aforesaid
Suggested fix:
Make LEAST in all surroundings behave as documented