數(shù)據(jù)庫中round的用法
數(shù)據(jù)庫中round的用法的用法你知道嗎?下面小編就跟你們詳細介紹下數(shù)據(jù)庫中round的用法的用法,希望對你們有用。
數(shù)據(jù)庫中round的用法的用法如下:
Access數(shù)據(jù)庫中Round用法
四舍五入的問題
select round(83.124,2) as t from jqdltb
顯示為:83.12
select round(83.125,2) as t from jqdltb
顯示為:83.12
select round(83.126,2) as t from jqdltb
顯示為:83.13
問題來了,就是四舍五入怎么變成五舍六入了呢?
下面是用這個方法來調(diào)整達到四舍五入的方法:
使用int函數(shù)和加0.005,然后*100,再然后/100
如下所示:
select int((83.121+0.005)*100)/100 as t from jqdltb
顯示為:83.12
select int((83.124+0.005)*100)/100 as t from jqdltb
顯示為:83.12
select int((83.125+0.005)*100)/100 as t from jqdltb
顯示為:83.13
select int((83.126+0.005)*100)/100 as t from jqdltb
顯示為:83.13
select int((83.129+0.005)*100)/100 as t from jqdltb
顯示為:83.13