MSSQL SERVER 2005 Mathematical function collation _mssql

Source: Internet
Author: User
Tags abs acos asin mssql mssql server natural logarithm sin square root
MSSQL SERVER 2005 Math functions
1. To find absolute value
ABS ()
Select Fweight-50,abs (FWeight-50), ABS ( -5.38) from T_person
2. Power
Power (x,y) is used to compute the Y-exponentiation of X
Select Fweight,power (fweight,-0.5), Power (fweight,2),
Power (fweight,3), Power (fweight,4) from T_person
Select Power (2,2)
3. Square root
SQRT ()
Select Fweight,sqrt (fweight) from T_person
4. Ask for random number
RAND () supports either parameters or no parameters
Select RAND ()
Select RAND (123)
5. Round to the largest integer
CEILING ()
Select Fname,fweight,ceiling (fweight), CEILING (fweight*-1) from T_person
6. Round to the smallest integer
FLOOR ()
Select Fname,fweight,floor (fweight), FLOOR (fweight*-1) from T_person
7. Rounding
ROUND ()
ROUND (M,d) m is the numeric value to be rounded, D is the precision of the calculation, that is, the number of decimal places retained when rounding
D to 0 means that decimal places are not preserved, and D is a negative value that is rounded in the integer portion.
Select Fname,fweight,round (fweight,1), ROUND (fweight*-1,0), ROUND (fweight,-1) from T_person
8. To find the sine value
SIN ()
Select Fname,fweight,sin (fweight) from T_person
9. Cosine value
COS ()
Select Fname,fweight,cos (fweight) from T_person
10. Ask for the strings anyway
ASIN ()
Select Fname,fweight,asin (1/fweight) from T_person
11. Reverse Cosine
ACOS ()
Select Fname,fweight,acos (1/fweight) from T_person
12. Calculate the Tangent value
TAN ()
Select Fname,fweight,tan (fweight) from T_person
13. Calculate the inverse tangent value
Atan ()
Select Fname,fweight,atan (fweight) from T_person
14. To find two variables of the tangent
ATN2 (X,y) is similar to calculating y/x's tangent
Select FNAME,FWEIGHT,ATN2 (fweight,2) from T_person
15. Ask Cotangent
COT ()
Select Fname,fweight,cot (fweight) from T_person
16. Calculate PI Value
PI ()
Select Fname,fweight,fweight*pi (), PI () from T_person
17. Radian Conversion to angle system
DEGREES () The accuracy of the results is related to the parameters
Select DEGREES (PI ()), DEGREES (3.0), DEGREES (3)
18. Angle system conversion to radian system
RADIANS () The accuracy of the results is related to the parameters
Select RADIANS (180), RADIANS (180.0)
19. Find the symbol
SIGN () returns a symbol of a numeric value that returns 1 if the value is greater than 0.
Returns 0 if the value equals 0, or 1 if the value is less than 0.
The accuracy of the results is related to the parameters
Select Fname,fweight-48.68,sign (FWeight-48.68), SIGN (1), SIGN (1.000) from T_person
20. Divide the remainder%
Select fname,fweight,fweight%5 from T_person
21. Find the natural logarithm
LOG ()
Select Fname,fweight,log (fweight), LOG (1.00) from T_person
22. To find the logarithm of 10 base
LOG10 ()
Select FNAME,FWEIGHT,LOG10 (fweight), LOG10 (MB) from T_person


Ps:

The main reference to the programmer's SQL code
The instance has changed.
Creation of T_person Tables
Copy Code code as follows:

CREATE TABLE T_person
(
Fidnumber varchar (20),
FName varchar (20),
Fbirthday datetime,
Fregday datetime,
Fweight Numeric (10,2),
)

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.