När du formaterar nummer till 2 decimaler har du två alternativ TRUNCATE och ROUND . Du letar efter TRUNCATE funktion.
Exempel:
Utan avrundning:
TRUNCATE(0.166, 2)
-- will be evaluated to 0.16
TRUNCATE(0.164, 2)
-- will be evaluated to 0.16
docs:https://www.w3resource.com/mysql /mathematical-functions/mysql-truncate-function.php
Med avrundning:
ROUND(0.166, 2)
-- will be evaluated to 0.17
ROUND(0.164, 2)
-- will be evaluated to 0.16
docs:https://www.w3resource.com/mysql /mathematical-functions/mysql-round-function.php