數(shù)據(jù)庫(kù)中round的用法
數(shù)據(jù)庫(kù)中round的用法的用法你知道嗎?下面小編就跟你們?cè)敿?xì)介紹下數(shù)據(jù)庫(kù)中round的用法的用法,希望對(duì)你們有用。
數(shù)據(jù)庫(kù)中round的用法的用法如下:
Access數(shù)據(jù)庫(kù)中Round用法
四舍五入的問(wèn)題
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
問(wèn)題來(lái)了,就是四舍五入怎么變成五舍六入了呢?
下面是用這個(gè)方法來(lái)調(diào)整達(dá)到四舍五入的方法:
使用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