简体   繁体   中英

Round off Value in sql query

I need to round off my value with some constraints. For example..

1. Value - 5.89
   Required solution  - 6.29

It's time difference value, which needs be rounded after every decimal value as 0.60. whenever, my decimal values reached at 60, it should rounded to the next value and remaining decimal value above 60, needs to be as it is.

Please suggest.

Its working for me in MS ACCESS

   select Format(YourField \ 60, '0') & '.' & Format(YourField Mod 60, '00') as [YourField] from YourTable

for SQL SERVER Try This,

select Right('0' + cast(YourField / 60) %60 as varchar),2)+ ':'+
right('0' + cast(YourField %60 as varchar),2 ) from YourTable

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