Find centralized, trusted content and collaborate around the technologies you use most.
Teams
Q&A for work
Connect and share knowledge within a single location that is structured and easy to search.
我有 2 位小数的数字,例如 12.09。我想四舍五入到 x9.90 或 xx9.90。
我有这个代码四舍五入到 xxx.90:
UPDATE x SET y = ROUND(col,1,2) + CASE WHEN y -(ROUND(col,1,2)) BETWEEN .00 AND .89 THEN .90 ELSE .90 END;
这应该有效:
UPDATE mytable SET col = col + CASE WHEN MOD(col, 10) <= 9.9 THEN 9.9 - MOD(col, 10) -- for x0.00 - x9.90 ELSE 19.9 - MOD(col, 10) -- for x9.91 - x9.99 END