當前位置

首頁 > 商務英語 > 計算機英語 > 數據庫中round的用法

數據庫中round的用法

推薦人: 來源: 閱讀: 1.48W 次

數據庫中round的用法的用法你知道嗎?下面小編就跟你們詳細介紹下數據庫中round的用法的用法,希望對你們有用。

padding-bottom: 75%;">數據庫中round的用法

  數據庫中round的用法的用法如下:

Access數據庫中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

問題來了,就是四捨五入怎麼變成五舍六入了呢?

下面是用這個方法來調整達到四捨五入的方法:

使用int函數和加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