简体   繁体   中英

How to round up to nearst decimals? E.g. 23.33 to final output to 23.5 and 23.55 to final output to 24

How to round up to nearst decimals? Eg 23.33 to final output to 23.5 and 23.55 to final output to 24

Use ceil() function to "round up to closest 0.5".

ceil(col * 2) / 2

The above will return -1 for -1.3. If you instead want -1.5, do

sign(col) * CEIL(ABS(col) * 2) / 2

https://dbfiddle.uk/L3bKT-V7

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.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM