trunc(exp1) trunc(exp1)和Round(exp1,exp2)類似,只不過trunc()不指定截取的小數位數進行處理,只取到整數位,不做捨去處理 select trunc(123.1234) from dual 123 select trunc(123.9234) from dua ...
trunc(exp1)
trunc(exp1)和Round(exp1,exp2)類似,只不過trunc()不指定截取的小數位數進行處理,只取到整數位,不做捨去處理
select trunc(123.1234) from dual ---123 select trunc(123.9234) from dual ---123
-----Round(exp1,exp2)函數具有四捨五入的功能,分為以下兩種情況 ---exp2數為非負,四捨五入的位數從小數點後開始計數,小數點後|exp2|位,看後一位,進本位,後面捨去 select Round(125.455,0) from dual ---125 select Round(125.455,1) from dual ---125.5 select Round(125.455,4) from dual ---125.455 大於小數位數,其餘的位數補0將不顯示 ---exp2數為負,四捨五入的位數從小數點前開始計數,小數點前|exp2|位,看本位,進前一位,本位以及後面取0 select Round(125.455,-1) from dual ---130 select Round(125.455,-2) from dual ---100 select Round(125.455,-3) from dual ---0 select Round(125.455,-4) from dual ---0