sql 之 round(),trunc(),floor(),ceil()函數

來源:互聯網
上載者:User
 1 trunc(value,precision)按精度(precision)截取某個數字,不進行舍入操作。 2 round(value,precision)根據給定的精度(precision)輸入數值。 3 ceil (value) 產生大於或等於指定值(value)的最小整數。 4 floor(value)與 ceil()相反,產生小於或等於指定值(value)的最小整數。 5 sign(value) 與絕對值函數ABS()相反。ABS()給出的是值的量而不是其符號,sign(value)則給出值的符號而不是量。 舉例如下:  trunc(11,2) = 11  trunc(-22,2) = -22  round(11,2) = 11  round(-22,2) = -22   trunc(33.33,2) = 33.33  trunc(-44.44,2) = -44.44  round(33.33,2) = 33.33  round(-44.44,2) = -44.44      trunc(55.5,2) = 55.5  trunc(-55.5,2) = -55.5

  round(55.5,2) = 55.5  round(-55.5,2) = -55.5   trunc(66.666,2) = 66.66 trunc(-77.777.5,2) = -77.77   round(66.666,2) = 66.67 round(-77.777,2) = -77.78因此只有小數位元大於精度時這兩個函數才起作用。   round(55.5) = 56   round(-55.5) = -56  trunc(55.5) = 55   trunc(-55.5) = -55  ceil(55.5) = 56    ceil(-55.5) = -55  floor(55.5) = 55   floor(-55.5) = -56  sign(146) = 1      ABS(146) = 146  sign(-30) = -1     ABS(-30) = 30  sign(0) = 0       

聯繫我們

該頁面正文內容均來源於網絡整理,並不代表阿里雲官方的觀點,該頁面所提到的產品和服務也與阿里云無關,如果該頁面內容對您造成了困擾,歡迎寫郵件給我們,收到郵件我們將在5個工作日內處理。

如果您發現本社區中有涉嫌抄襲的內容,歡迎發送郵件至: info-contact@alibabacloud.com 進行舉報並提供相關證據,工作人員會在 5 個工作天內聯絡您,一經查實,本站將立刻刪除涉嫌侵權內容。

A Free Trial That Lets You Build Big!

Start building with 50+ products and up to 12 months usage for Elastic Compute Service

  • Sales Support

    1 on 1 presale consultation

  • After-Sales Support

    24/7 Technical Support 6 Free Tickets per Quarter Faster Response

  • Alibaba Cloud offers highly flexible support services tailored to meet your exact needs.