Search code examples
mysql

MySQL Round Up to Nearest 5 Cents


I need to round up values using MySQL to increments of 5 cents (0.05). It has to ALWAYS round up. Examples:

0.01 -> 0.05

2.12 -> 2.15

0.16 -> 0.20

How can I accomplish this. I tried a few things with ceil() and round(), but it seems like I can use some help from a MySQL expert.


Solution

  • Try to use this one -

    SELECT (<value> DIV 0.05) * 0.05 + IF(<value> MOD 0.05 = 0, 0, 0.05)