Når du formaterer tal til 2 decimaler, har du to muligheder TRUNCATE
og ROUND
. Du leder efter TRUNCATE
funktion.
Eksempler:
Uden afrunding:
TRUNCATE(0.166, 2)
-- will be evaluated to 0.16
TRUNCATE(0.164, 2)
-- will be evaluated to 0.16
docs:http://www.w3resource.com/mysql /mathematical-functions/mysql-truncate-function.php
Med afrunding:
ROUND(0.166, 2)
-- will be evaluated to 0.17
ROUND(0.164, 2)
-- will be evaluated to 0.16
docs:http://www.w3resource.com/mysql /mathematical-functions/mysql-round-function.php