SQL Server functions full solution < two > math functions

Source: Internet
Author: User
Tags acos asin cos mathematical functions natural logarithm sin square root

Read Catalogue

    • 1. Absolute function abs (x) and function Pi returning pi ()
    • 2. square root function sqrt (x)
    • 3. Functions for obtaining random functions rand () and rand (x)
    • 4. Rounding function round (x, y)
    • 5. Symbol function sign (x)
    • 6. Functions that get integers ceiling (x) and floor (x)
    • 7. Power Operation function Power (x, y), SQUARE (x), and exp (×)
    • 8. Logarithmic operation log (x) and LOG10 (x)
    • 9. Functions Randians (x) and degrees (x) for the conversion of angles and radians
    • 10. Sine function sin (x) and inverse chord function asin (x)
    • 11. Cosine function cos (x) and inverse cosine function acos (x)
    • 12. Tangent function tan (x), Inverse tangent function atan (x) and cotangent function cot (x)

Mathematical functions are mainly used to deal with numerical data, the main mathematical functions are: absolute value function, trigonometric functions (including sine function, cosine function, tangent function, cotangent function), logarithmic function, random function and so on. In the case of an error, the math function returns a null value of NULL. This article introduces the functions and usages of various mathematical functions.

Back to top 1. Absolute function abs (x) and return pi function pi () ABS (x) returns the absolute value of x, Pi () returns the values of Pi (Eg:select abs (2), ABS ( -3.3), ABS ( -33), Pi (); the absolute value of a positive number is itself, The absolute value of 2 is 2, the absolute value of the negative is the opposite number, and the absolute value of 3.3 is 3.3,-33 33. Back to top 2. The square root function SQRT (x) SQRT (x) returns the two root of the non-negative x eg:select  SQRT (9), SQRT (40), and back to the top 3. Functions for obtaining random functions rand () and rand (x) rand (x) Returns a random floating-point value of V, in the range between 0~1 (that is, 0<=v<=1.0). If you specify an integer parameter x, it is used as the seed value, and the same seed number will produce a repeating sequence. If the same seed value calls the RAND function multiple times, it returns the same build value. Eg:select rand (), RAND (), Rand (); You can see that rand () with no parameters produces a different value each time. Eg:select rand (TEN), Rand (11); As you can see, when rand (x) 's parameters are the same, the same random number is generated, and the random values produced by the different x are different. Back to top 4. The Rounding function ROUND (x, y) ROUND (x, y) returns the number close to the parameter x, its value remains to the Y-bit after the decimal point, and if Y is negative, the X value is preserved to the left Y-bit of the decimal point. Eg:select ROUND (1.38,1),  ROUND (1.38,0), ROUND (232.38,-1),  ROUND (232.38,-2);  round (1.38,1) retains one after the decimal point, rounding the result to 1.4;round (1.38,0) retains 0 bits after the decimal point, that is, returns the rounded integer value, ROUND (232.38,-1) and ROUND (232.38,-2) Leave 1 and 2 digits to the left of the decimal point respectively. Back to top 5. Symbol function sign (x) sign (x) returns the symbol for the parameter, the value of x is negative, 0, or positive, and the result is 1, 0, or 1. Eg:select sign ( -21), sign (0), sign (21); Sign (-21) returns -1,sign (0) returns 0,sign (21) returns 1 back to top 6. A function that gets an integer CEILING (x) and floor (x) CEILING (x) returns the smallest integer value not less than X, floor(x) returns the maximum integer value not greater than X; Eg:select CEILING ( -3.35), CEILING (3.35), Floor ( -3.35), floor (3.35); (1), 3.35 is negative, not less than 3.35 of the smallest integer is-3, not less than 3.35 of the smallest integer value is 4 (2), 3.35 is negative, not greater than 3.35 of the smallest integer is-4, the smallest integer value not greater than 3.35 is 3 back to the top 7. Power function power (x, y ), SQUARE (x), and exp (x) (i). The  power (x, y) function returns the result value of the Y-exponent of X; (ii). The  square (x) function returns the square of the specified floating-point value x; (iii). The &NBSP;EXP (x) function returns the value after the X-exponentiation of E. Eg:select  power (2,2), POWER (2.00,-2),   square (3),  square ( -3),  square (0),  exp (3),  exp ( -3),  exp (0); You can see that POWER (2,2) returns the square of 2, with the result that 4;power (2.00,-2) returns 2-2 squares, the result is 0.25;square (3) returns 3 squared, and the result is 9;square (-3) returns-3 squared, resulting in;  Square (0) returns the square of 0, the result is 0;exp (3) returns the base of the 3 square, the result is 20.0855369231877, exp (-3) returns the bottom of the E-3 times, the result is 0.0497870683678639;exp (0 ) returns the 0-time base of e, with a result of 1. Back to top 8. Logarithm of the operation log (x) and LOG10 (x) log (x) returns the natural logarithm of x, X relative to the logarithm of Cardinal E. LOG10 (x) returns the logarithm of the cardinality of X of 10. Eg:select log (3), log (6), LOG10 (1), LOG10 (+), LOG10 (1000); The logarithm definition field cannot be negative, 10 of 0 is 1, so LOG10 (1) Returns the result is 0,10 2 is 100, so LOG10 (100) Returns the result is 2,10 3 is 1000, so LOG10 (1000) Returns the result is 3 Back to top 9. The function Randians (x) and degrees (x) Randians (x) of the angle and radians convert the parameter x from the angle to the radian. DEGREES (X) converts the parameter x to a radian to an angle. Eg: select RADIANS (90.0), RADIANS (180.0), DEGREES (Pi ()/2), DEGREES (Pi ()); Back to top 10. Sine function sin (x) and inverse chord function asin (x) sin (x) Returns the sine of x, where x is the Radian value, and ASIN (x) returns the inverse of x, the value of sine x, or null if X is not in the range of 1 to 1. Eg:select sin (pi ()/2), Sin (Pi ()), ASIN (1), ASIN (0); back to top 11. Cosine function COS (x) and inverse cosine function ACOS (x) cos (x) returns the cosine of x, where x is the radian value; ACOS (x) Returns the inverse cosine of x, which is the value of cosine x. If x is not within the range of 1 to 1, then return null;eg:select cos (0), cos (PI ()), ACOS (1), ACOS (0), back to top 12. Tangent function TAN (x), Inverse tangent function atan (x) and cotangent function Cot (x) TAN (x) Returns the tangent of x, where x is the given radian value; ATAN (x) returns the inverse tangent of x, which is the value of tangent x; COT (x) returns the cotangent of X. Eg:  select TAN (0.3), ROUND (Tan (pi ()/2), 0), ATAN (0.30933624960962325), ATAN (1), cot (0.3), 1/tan (0.3), cot (pi ()/4) ;

SQL Server functions full solution < two > math functions

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.