SQL statement Daquan (2) _ FUNCTION Daquan

Source: Internet
Author: User
Tags natural logarithm

---- Arithmetic functions ----

/*** Trigonometric function ***/
Sin (float_expression) -- returns the sine of the angle in radians
Cos (float_expression) -- returns the cosine of the angle in radians
Tan (float_expression) -- returns the tangent of the angle in radians
Cot (float_expression) -- returns the cotangent of the angle in radians
/*** Inverse trigonometric function ***/
Asin (float_expression) -- returns the angle in radians where the sine is the float value.
ACOs (float_expression) -- returns the angle in radians where the cosine is the float value.
Atan (float_expression) -- returns the angle in radians of the float value.
Atan2 (float_expression1, float_expression2)
-- Returns the radians of float_expression1/float_expres-sion2.
Degrees (numeric_expression)
-- Converts radians to degrees and returns data of the same type as the expressions.
-- Integer/money/real/Float Type
Radians (numeric_expression) -- converts degrees to radians and returns the same data type as the expression.
-- Integer/money/real/Float Type
Exp (float_expression) -- returns the exponent value of the expression.
Log (float_expression) -- returns the natural logarithm of the expression.
Log10 (float_expression) -- returns the base-10 logarithm of the expression.
SQRT (float_expression) -- returns the square root of the expression
/***** Approximate function ***/
Ceiling (numeric_expression) -- Return> = the minimum integer of the expression. The returned data type is the same as that of the expression.
-- Integer/money/real/Float Type
Floor (numeric_expression) -- returns the minimum integer of the <= expression. The returned data type is the same as that of the expression.
-- Integer/money/real/Float Type
Round (numeric_expression) -- returns the data returned from a rounding value with integer_expression as the precision.
-- The same type and expression can be integer/money/real/Float Type
ABS (numeric_expression) -- returns the absolute value of the expression. The returned data type is the same as that of the expression.
-- Integer/money/real/Float Type
Sign (numeric_expression) -- the positive and negative values of the test parameter return the data type returned by 0, zero, 1, positive, or-1 negative.
-- Same as the expression, it can be of the integer, money, real, or float type.
Pi () -- the return value is π, that is, 3.1415926535897936
Rand ([integer_expression]) -- use the optional [integer_expression] As the seed value to obtain a random floating point number between 0 and 1.

---- String function ----
ASCII () -- returns the ASCII value of the leftmost character of a character expression.
Char () -- function used to convert ASCII code to character
-- If no value is entered ~ The Char function returns a null value for the ASCII value between 255.
Lower () -- function converts all strings to lowercase letters
Upper () -- function converts all strings to uppercase
STR () -- function converts numeric data to numeric data
Ltrim () -- function removes spaces in the string Header
Rtrim () -- function removes spaces at the end of the string
Left (), right (), substring () -- The function returns some strings.
Charindex (), patindex () -- The function returns the starting position of a specified substring in the string.
Soundex () -- The function returns a four-digit escape code.
-- The soundex function can be used to find strings with similar sound. However, the soundex function returns only 0 values for numbers and Chinese characters.
Difference () -- the difference between the two character expressions returned by the soundex Function
-- 0 the first character returned by the two soundex functions is different
-- 1 the first character returned by the two soundex functions is the same
-- 2 two soundex functions return the same first and second characters.
-- 3 two soundex functions return the same first, second, and third characters.
-- 4 two soundex functions return identical values

Quotename () -- The function returns a string enclosed by a specific character.
/* Select quotename ('abc', '{') quotename ('abc ')
The running result is as follows:
----------------------------------{
{ABC} [ABC] */

Replicate () -- The function returns a string that repeats character_expression for a specified number of times.
/* Select replicate ('abc', 3) replicate ('abc',-2)
The running result is as follows:
----------------------
Abcabcabc null */

Reverse () -- The function reverses the character arrangement order of the specified string
Replace () -- returns the string with the specified substring replaced by the function.
/* Select Replace ('abc123g ', '123', 'def ')
The running result is as follows:
----------------------
Abcdefg */

Space () -- The function returns a blank string with a specified length.
Stuff () -- The function replaces a substring of the specified position length with another substring.

---- Data type conversion function ----
The syntax of the cast () function is as follows:
Cast () (<expression> as <data _ type> [length])
The convert () function syntax is as follows:
Convert () (<data _ type> [length], <expression> [, style])

Select cast (100 + 99 as char) convert (varchar (12), getdate ())
The running result is as follows:
------------------------------------------
199 Jan 15 2000

---- Date function ----
Day () -- The function returns the date value in date_expression.
Month () -- The function returns the month value in date_expression.
Year () -- returns the Year Value in date_expression.
Dateadd (<datepart>, <number>, <date>)
-- The function returns the new date generated by the specified date plus the specified additional date interval number.
Datediff (<datepart >,< number >,< date>)
-- The function returns the datepart differences between two specified dates.
Datename (<datepart>, <date>) -- The function returns the specified part of the date in the form of a string.
Datepart (<datepart >,< date>) -- The function returns the specified part of the date in the form of an integer.
Getdate () -- The function returns the current date and time of the system in the default format of datetime.

---- System functions ----
App_name () -- function returns the name of the currently executed application
Coalesce () -- function returns the value of the first non-null expression among multiple expressions.
Col_length (<'table _ name' >,< 'column _ name'>) -- returns the length value of the specified field in the table.
Col_name (<table_id >,< column_id>) -- the name of the specified field in the function return table is the column name.
Datalength () -- the actual length of the data returned by the function
Db_id (['database _ name']) -- number of the database returned by the function
Db_name (database_id) -- Name of the database returned by the function
Host_id () -- The function returns the name of the server computer.
Host_name () -- returns the name of the server computer.
Identity (<data_type> [, seed increment]) [as column_name])
-- The identity () function is used only in the select into statement to insert an identity column to the new table.
/* Select Identity (INT, 1, 1) as column_name
Into newtable
From oldtable */
Isdate () -- determines whether the given expression is a reasonable date.
Isnull (<check_expression >,< replacement_value>) -- The function replaces the null value in the expression with the specified value.
Isnumeric () -- The function determines whether the given expression is a reasonable value.
Newid () -- The function returns a value of the uniqueidentifier type.
Nullif (<expression1>, <expression2>)
-- The nullif function returns the value of expression1 if expression1 is equal to expression2. If the value is not equal, the return value is expression1.

 

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.