MaxCompute SQL函式詳解 ODPS SQL函式詳解---之常用數學運算相關函式
MaxCompute/ODPS SQL常用數學運算相關函式
- ABS函式-計算絕對值
sql:
select ABS(-2.5) as 負數絕對值,ABS(2.5) as 正數絕對值
;
函式作用:計算數字的絕對值
舉例:

2. RAND 函式-亂數
回傳值:double
函式體:rand(bigint seed)
函式作用:計算以seed為基礎,回傳一個double型別的亂數,回傳值區間是的0-1;
sql:
select rand(12) as 亂數
;
舉例:

- ROUND 函式-四舍五入到指定小數點
回傳值:double
函式體:round(double number, [bigint decimal_places])
回傳值:decimal
函式體:round(decimal number, [bigint decimal_places])
函式作用:計算一個數值的四舍五入指定小數位;
decimal_places可以是負數,負數會從小數點向左開始計數,并且不保留小數部分,
舉例:

- pow 函式-指數函式
回傳值:double
函式體:pow(double x, double, y)
回傳值:decimal
函式體:pow(decimal x, decimal, y)
函式作用:計算x的y次方,
舉例:

- sign 函式- 標記正、負、0
回傳值:double
函式體:pow(double x, double, y)
回傳值:decimal
函式體:pow(decimal x, decimal, y)
函式作用:標記正數、負數、0,引數為空時,拋例外,
舉例:

- log 函式- 計算對數
回傳值:double
函式體:log(double base, double x)
回傳值:decimal
函式體:log(decimal base, decimal x)
函式作用:計算以base為底x的對數的值,
舉例:

- floor 函式- 向下取整
回傳值:bigint
函式體:floor(double number)
回傳值:bigint
函式體:floor(double number)
函式作用:回傳number向下取整的值,取到整數位,
舉例:

- ceil 函式- 向上取整
回傳值:bigint
函式體:ceil(double number)
回傳值:bigint
函式體:ceil(decimal number)
函式作用:回傳number向上取整的值,取到整數位(計算不小于number的最小整數),
舉例:

- sqrt 函式- 計算平方根的值
回傳值:double
函式體:sqrt(double number)
回傳值:decimal
函式體:sqrt(decimal number)
函式作用:計算number的平方根的值,
舉例:

- conv 函式- 轉換進制
回傳值:string
函式體:conv(string number, bigint from_base, bigint to_base)
函式作用:對number進行進制轉換,對number由from_base進制轉換成to_base進制
舉例:

- 不常用函式
sin:
double sin(double number)
作用:number正玄函式
asin:
double asin(double number)
decimal asin(decimal number)
作用:number的反正玄函式
cos:
double cos(double number)
decimal cos(decimal number)
作用:number的余玄函式
acos:
double acos(double number)
decimal acos(decimal number)
作用:number的反余玄函式
tan:
double tan(double number)
decimal tan(decimal number)
作用:計算number正切函式
atan:
double atan(double number)
作用:計算number反正切函式
cot:
double cot(double number)
decimal cot(decimal number)
作用:計算number的余切函式
cosh:
double cosh(double number)
decimal cosh(decimal number)
作用:計算number的雙余玄函式
sinh:
double sinh(double number)
decimal sinh(decimal number)
作用:計算number雙曲正玄函式
tanh:
double tanh(double number)
decimal tanh(decimal number)
作用:計算number雙曲正切函式
exp:
double exp(double number)
decimal exp(decimal number)
作用:指數函式(以e=2.718281828459045為底數)
轉載請註明出處,本文鏈接:https://www.uj5u.com/qita/423402.html
標籤:其他
上一篇:MaxCompute SQL函式詳解 ODPS SQL函式詳解---之聚合相關函式
下一篇:MySQL高級查詢
