亚洲国产日韩欧美在线a乱码,国产精品路线1路线2路线,亚洲视频一区,精品国产自,www狠狠,国产情侣激情在线视频免费看,亚洲成年网站在线观看

My SQL數(shù)學(xué)函數(shù)總結(jié)

時(shí)間:2020-11-11 12:36:18 SQL 我要投稿

My SQL數(shù)學(xué)函數(shù)總結(jié)

  1. ABS(x): 返回x的絕對(duì)值

My SQL數(shù)學(xué)函數(shù)總結(jié)

  復(fù)制代碼 代碼如下:

  mysql> select ABS(1), ABS(-1), ABS(0);

  +--------+---------+--------+

  | ABS(1) | ABS(-1) | ABS(0) |

  +--------+---------+--------+

  | 1 | 1 | 0 |

  +--------+---------+--------+

  2. PI(): 返回圓周率

  復(fù)制代碼 代碼如下:

  mysql> select PI();

  +----------+

  | PI() |

  +----------+

  | 3.141593 |

  +----------+

  3. SQRT(x): 返回x的平方根,要求(x為非負(fù)數(shù),返回NULL)

  復(fù)制代碼 代碼如下:

  mysql> select SQRT(49), SQRT(0), SQRT(-49);

  +----------+---------+-----------+

  | SQRT(49) | SQRT(0) | SQRT(-49) |

  +----------+---------+-----------+

  | 7 | 0 | NULL |

  +----------+---------+-----------+

  4. MOD(x,y): 求余函數(shù),返回x被y除后的余數(shù);對(duì)于帶有小數(shù)部分的數(shù)據(jù)值也起作用,它返回除法運(yùn)算后的精確余數(shù)。

  復(fù)制代碼 代碼如下:

  mysql> select MOD(31,8), MOD(21,-8), MOD(-7,2), MOD(-7,-2), MOD(45.5,6);

  +-----------+------------+-----------+------------+-------------+

  | MOD(31,8) | MOD(21,-8) | MOD(-7,2) | MOD(-7,-2) | MOD(45.5,6) |

  +-----------+------------+-----------+------------+-------------+

  | 7 | 5 | -1 | -1 | 3.5 |

  +-----------+------------+-----------+------------+-------------+

  5. CEIL(X): 返回不小X的最小整數(shù)值,返回值轉(zhuǎn)為一個(gè)BIGINT.

  復(fù)制代碼 代碼如下:

  mysql> select CEIL(-3.35), CEIL(3.35);

  +-------------+------------+

  | CEIL(-3.35) | CEIL(3.35) |

  +-------------+------------+

  | -3 | 4 |

  +-------------+------------+

  6. CEILING(X): 同CEIL(X)

  復(fù)制代碼 代碼如下:

  mysql> select CEILING(-3.35), CEILING(3.35);

  +----------------+---------------+

  | CEILING(-3.35) | CEILING(3.35) |

  +----------------+---------------+

  | -3 | 4 |

  +----------------+---------------+

  7. FLOOR(X):返回不大于X的最大整數(shù)值,返回值轉(zhuǎn)為一個(gè)BIGINT.

  復(fù)制代碼 代碼如下:

  mysql> select FLOOR(-3.35), FLOOR(3.35);

  +--------------+-------------+

  | FLOOR(-3.35) | FLOOR(3.35) |

  +--------------+-------------+

  | -4 | 3 |

  +--------------+-------------+

  8. RAND()和RAND(X)

  RAND(X) 返回一個(gè)隨機(jī)浮點(diǎn)值,范圍在0~1之間,X為整數(shù),它被稱(chēng)作種子值,用來(lái)產(chǎn)生重復(fù)序列。即當(dāng)X值相同時(shí),產(chǎn)生的隨機(jī)數(shù)也相同;

  復(fù)制代碼 代碼如下:

  mysql> select RAND(10), RAND(10), RAND(2), RAND(-2);

  +--------------------+--------------------+--------------------+--------------------+

  | RAND(10) | RAND(10) | RAND(2) | RAND(-2) |

  +--------------------+--------------------+--------------------+--------------------+

  | 0.6570515219653505 | 0.6570515219653505 | 0.6555866465490187 | 0.6548542125661431 |

  +--------------------+--------------------+--------------------+--------------------+

  RAND(): 不帶參數(shù)的RAND()每次產(chǎn)生不同0~1之間的隨機(jī)數(shù)

  復(fù)制代碼 代碼如下:

  mysql> SELECT RAND(), RAND(), RAND();

  +--------------------+--------------------+---------------------+

  | RAND() | RAND() | RAND() |

  +--------------------+--------------------+---------------------+

  | 0.6931893636409094 | 0.5147262984092592 | 0.49406343185721285 |

  +--------------------+--------------------+---------------------+

  9. ROUND(X)和ROUND(X,Y): 四舍五入函數(shù),對(duì)X值按照Y進(jìn)行四舍五入,Y可以省略,默認(rèn)值為0;若Y不為0,則保留小數(shù)點(diǎn)后面指定Y位。

  復(fù)制代碼 代碼如下:mysql> select ROUND(-1.14), ROUND(-1.9), ROUND(1.14), ROUND(1.9);

  +--------------+-------------+-------------+------------+

  | ROUND(-1.14) | ROUND(-1.9) | ROUND(1.14) | ROUND(1.9) |

  +--------------+-------------+-------------+------------+

  | -1 | -2 | 1 | 2 |

  +--------------+-------------+-------------+------------+

  mysql> select ROUND(1.38,1), ROUND(1.38,0), ROUND(232.38,-1), ROUND(232.38,-2);

  +---------------+---------------+------------------+------------------+

  | ROUND(1.38,1) | ROUND(1.38,0) | ROUND(232.38,-1) | ROUND(232.38,-2) |

  +---------------+---------------+------------------+------------------+

  | 1.4 | 1 | 230 | 200 |

  +---------------+---------------+------------------+------------------+

  10. TRUNCATE(X,Y): 與ROUND(X,Y)功能類(lèi)似,但不進(jìn)行四舍五入,只進(jìn)行截取。

  復(fù)制代碼 代碼如下:

  mysql> select TRUNCATE(1.33,1), TRUNCATE(1.99,1), TRUNCATE(1.99,0), TRUNCATE(19.99,-1);

  +------------------+------------------+------------------+--------------------+

  | TRUNCATE(1.33,1) | TRUNCATE(1.99,1) | TRUNCATE(1.99,0) | TRUNCATE(19.99,-1) |

  +------------------+------------------+------------------+--------------------+

  | 1.3 | 1.9 | 1 | 10 |

  +------------------+------------------+------------------+--------------------+

  11. SIGN(X): 返回參數(shù)X的`符號(hào),X的值為負(fù)、零或正數(shù)時(shí)返回結(jié)果依次為-1,0或1

  復(fù)制代碼 代碼如下:mysql> select SIGN(-21), SIGN(-0),SIGN(0), SIGN(0.0), SIGN(21);

  +-----------+----------+---------+-----------+----------+

  | SIGN(-21) | SIGN(-0) | SIGN(0) | SIGN(0.0) | SIGN(21) |

  +-----------+----------+---------+-----------+----------+

  | -1 | 0 | 0 | 0 | 1 |

  +-----------+----------+---------+-----------+----------+

  12. POW(X,Y), POWER(X,Y)和EXP(X)

  POW(X,Y)與POWER(X,Y)功能相同,用于返回X的Y次乘方的結(jié)果值

  復(fù)制代碼 代碼如下:mysql> select pow(2,2), pow(2,-2), pow(-2,2), pow(-2,-2);

  +----------+-----------+-----------+------------+

  | pow(2,2) | pow(2,-2) | pow(-2,2) | pow(-2,-2) |

  +----------+-----------+-----------+------------+

  | 4 | 0.25 | 4 | 0.25 |

  +----------+-----------+-----------+------------+

  mysql> select power(2,2), power(2,-2), power(-2,2), power(-2,-2);

  +------------+-------------+-------------+--------------+

  | power(2,2) | power(2,-2) | power(-2,2) | power(-2,-2) |

  +------------+-------------+-------------+--------------+

  | 4 | 0.25 | 4 | 0.25 |

  +------------+-------------+-------------+--------------+

  EXP(X): 返回e的X乘方后的值:

  復(fù)制代碼 代碼如下:

  mysql> select EXP(3), EXP(0), EXP(-3);

  +-------------------+--------+---------------------+

  | EXP(3) | EXP(0) | EXP(-3) |

  +-------------------+--------+---------------------+

  | 20.08553692318767 | 1 | 0.04978706836786393 |

  +-------------------+--------+---------------------+

  13. LOG(X)和LOG10(X): 對(duì)數(shù)運(yùn)算函數(shù)(X必須為正數(shù)),LOG(X)-返回X的自然對(duì)數(shù)(X相對(duì)于基數(shù)e的對(duì)數(shù))LOG10(X)-返回x的基數(shù)為10的對(duì)數(shù):

  復(fù)制代碼 代碼如下:

  mysql> select LOG(-3), LOG(0), LOG(3), LOG10(-100), LOG10(0), LOG10(100);

  +---------+--------+--------------------+-------------+----------+------------+

  | LOG(-3) | LOG(0) | LOG(3) | LOG10(-100) | LOG10(0) | LOG10(100) |

  +---------+--------+--------------------+-------------+----------+------------+

  | NULL | NULL | 1.0986122886681098 | NULL | NULL | 2 |

  +---------+--------+--------------------+-------------+----------+------------+

  14. RADIANS(X) 和 DEGREES(X): 角度與弧度轉(zhuǎn)換函數(shù)

  復(fù)制代碼 代碼如下:

  mysql> select RADIANS(90), RADIANS(180), DEGREES(PI()), DEGREES(PI()/2);

  +--------------------+-------------------+---------------+-----------------+

  | RADIANS(90) | RADIANS(180) | DEGREES(PI()) | DEGREES(PI()/2) |

  +--------------------+-------------------+---------------+-----------------+

  | 1.5707963267948966 | 3.141592653589793 | 180 | 90 |

  +--------------------+-------------------+---------------+-----------------+

  15. SIN(X), ASIN(X), COS(X), ACOS(X), TAN(X), ATAN(X), COT(X)

  SIN(X): 正弦函數(shù),其中X為弧度值

  ASIN(X): 反正弦函數(shù)其中X必須在-1到1之間

  COS(X): 余弦函數(shù),其中X為弧度值

  ACOS(X): 反余弦函數(shù)其中X必須在-1到1之間

  TAN(X): 正切函數(shù),其中X為弧度值

  ATAN(X): 反正切函數(shù),ATAN(X)與TAN(X)互為反函數(shù)

  COT(X):余切函數(shù),函數(shù)COT和TAN互為倒函數(shù)

  復(fù)制代碼 代碼如下:

  mysql> select SIGN(PI()/2),ASIN(1),COS(PI()), ACOS(-1), TAN(PI()/4), ATAN(1), COT(0.5);

  +--------------+--------------------+-----------+-------------------+--------------------+--------------------+-------------------+

  | SIGN(PI()/2) | ASIN(1) | COS(PI()) | ACOS(-1) | TAN(PI()/4) | ATAN(1) | COT(0.5) |

  +--------------+--------------------+-----------+-------------------+--------------------+--------------------+-------------------+

  | 1 | 1.5707963267948966 | -1 | 3.141592653589793 | 0.9999999999999999 | 0.7853981633974483 | 1.830487721712452 |

  +--------------+--------------------+-----------+-------------------+--------------------+--------------------+-------------------+

【My SQL數(shù)學(xué)函數(shù)總結(jié)】相關(guān)文章:

1.SQL中的單記錄函數(shù)

2.SQL中的單記錄函數(shù)盤(pán)點(diǎn)

3.sql max函數(shù)的使用方法

4.SQL中的單記錄函數(shù)有哪些

5.SQL server中字符串逗號(hào)分隔函數(shù)

6.SQL的SUBSTR 函數(shù)的使用方法介紹

7.PHP數(shù)學(xué)運(yùn)算函數(shù)大匯總

8.SQL優(yōu)化大全