I need to round 'half down' for a number and keep the (.5), for example:
if number = (9115.7 ) then (9116)
if number = (9115.5 ) then (9115.5)
if number = (9115.3 ) then (9115)
You could rewrite own rounding logic using case expression:
CREATE TABLE t
AS
SELECT 9115.7 AS col FROM dual UNION ALL
SELECT 9115.5 AS col FROM dual UNION ALL
SELECT 9115.3 AS col FROM dual;
SELECT col, CASE WHEN MOD(ABS(col),1) = 0.5 THEN col ELSE ROUND(col) END
FROM t;
Output:
+---------+---------+
| COL | ROUNDED |
+---------+---------+
| 9115.7 | 9116 |
| 9115.5 | 9115.5 |
| 9115.3 | 9115 |
+---------+---------+
The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.