MySql digital functions

Source: Internet
Author: User
Tags acos asin natural logarithm

MySql numeric functions abs (N) returns the absolute value of N www.2cto.com mysql> select ABS (2);-> 2 mysql> select ABS (-32);-> 32 sign (N) returns the parameter symbol (-1, 0, or 1) mysql> select SIGN (-32);->-1 mysql> select SIGN (0 ); -> 0 mysql> select SIGN (234);-> 1 mod (N, M) modulo operation, returns the remainder of N divided by M (same as the % operator) www.2cto.com mysql> select MOD (234, 10);-> 4 mysql> select 234% 10;-> 4 mysql> select MOD ();-> 2 floor (N) returns the maximum integer of N. mysql> select FLOOR (1.23);-> 1 mysql> select FLOOR (-1.23);->-2 ceiling (N) returns the smallest integer value of N. mysql> select CEILING (1.23);-> 2 mysql> select CEILING (-1.23);->-1 round (N, D) returns the rounding value of N and retains the D-decimal places (the default value of D is 0). mysql> select ROUND (-1.23);->-1 mysql> select ROUND (-1.58 ); ->-2 mysql> select ROUND (1.58);-> 2 mysql> select ROUND (1.298, 1);-> 1.3 mysql> select ROUND (1.298, 0 ); -> 1 exp (N) returns the N power of e (base of the natural logarithm) mysql> select EXP (2);-> 7.389056 mysql> select EXP (-2 ); -> 0.135335 log (N) returns the natural logarithm of N mysql> select LOG (2);-> 0.693147 mysql> select LOG (-2);-> NULL log10 (N) returns the base-10 logarithm of N mysql> select LOG10 (2);-> 0.301030 mysql> select LOG10 (100);-> 2.000000 mysql> select LOG10 (-100 ); -> NULL pow (X, Y) or power (X, Y) returns the Y power of X mysql> select POW (4.000000);-> mysql> select POW (2, -2);-> 0.250000 sqrt (N) returns the square root of non-negative N mysql> select SQRT (4);-> 2.000000 mysql> select SQRT (20 ); -> 4.472136 pi () returns the circumference rate mysql> select PI ();-> 3.141593 cos (N) returns the cosine of N mysql> select COS (PI ()); ->-1.000000 sin (N) returns the sine of N. mysql> select SIN (PI ();-> 0.000000 tan (N) returns the tangent of N. mysql> select TAN (PI () + 1);-> 1.557408 acos (N) returns N arc cosine (N is the cosine value, in the range from-1 to 1, otherwise NULL is returned.) mysql> select ACOS (1);-> 0.000000 mysql> select ACOS (1.0001 ); -> NULL mysql> select ACOS (0);-> 1.570796 asin (N) returns N arcsin mysql> select ASIN (0.2 ); -> 0.201358 mysql> select ASIN ('foo');-> 0.000000 atan (N) returns the arc tangent value of N mysql> select ATAN (2 ); -> 1.107149 mysql> select ATAN (-2);->-1.107149 atan2 (X, Y) returns the arc tangent of two variables X and Y (similar to the arc tangent of Y/X, the symbol determines the quadrant) mysql> select ATAN ); ->-0.785398 mysql> select ATAN (PI (), 0);-> 1.570796 cot (N) returns X's cotangent mysql> select COT (12 ); ->-1.57267341 mysql> select COT (0);-> null rand () or RAND (N) returns a random floating point value ranging from 0 to 1.0 (the number N can be used as the initial value) mysql> select RAND ();-> 0.5925 mysql> select RAND (20 ); -> 0.1811 mysql> select RAND (20);-> 0.1811 mysql> select RAND ();-> 0.2079 mysql> select RAND ();-> 0.7888 degrees (N) converts N from radians to DEGREES and returns mysql> select DEGREES (PI ();-> 180.000000 radians (N) converts N from angle to radian and returns mysql> select RADIANS (90);-> 1.570796 truncate (N, D) retain the D decimal places of the number N and return mysql> select TRUNCATE (1.223, 1);-> 1.2 mysql> select TRUNCATE (1.999, 1 ); -> 1.9 mysql> select TRUNCATE (1.999, 0);-> 1 least (X, Y ,...) returns the minimum value (if the return value is used in the context of an integer (real number or size-sensitive string) or if all parameters are integers (real number or size-sensitive string), they are used as integers (real number or size-sensitive string) otherwise, the case-insensitive strings are compared.) www.2cto.com mysql> select LEAST (34.0);-> 0 mysql> select LEAST (3.0, 5.0, 767.0 ); -> 3.0 mysql> select LEAST ("B", "A", "C");-> "A" greatest (X, Y ,...) returns the maximum value (other values are the same as LEAST () mysql> select GREATEST (34.0);-> 2 mysql> select GREATEST (3.0, 5.0, 767.0 ); -& gt; 767.0 mysql & gt; select GREATEST ("B", "A", "C");-& gt; "C"
 

Related Article

Contact Us

The content source of this page is from Internet, which doesn't represent Alibaba Cloud's opinion; products and services mentioned on that page don't have any relationship with Alibaba Cloud. If the content of the page makes you feel confusing, please write us an email, we will handle the problem within 5 days after receiving your email.

If you find any instances of plagiarism from the community, please send an email to: info-contact@alibabacloud.com and provide relevant evidence. A staff member will contact you within 5 working days.

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.