Javatpoint Logo
Javatpoint Logo

T-SQL Numeric function

In T-SQL, a Numeric function is applied to numeric data and returns digital data.

The types of Numeric function are given below:

  • ABS ()

The absolute value is returned as the output of the numeric expression.

Example

The query returns the absolute value.

  • ACOS ()

The arc cosine value is returned as the output of the numeric expression that is specified.

Example

The below code generates the arc cosine value of 0.

  • ASIN()

Arc sine value is returned as the output of the specific numeric value expression.

Example

The query gives the arc sine value of 0.

  • ATAN ()

The arc tangent value is returned as the output of the specific numeric expression.

Examples:

The query returns an arc tangent value 0

  • ATN2 ()

The Arc tangent value in all the four quadrants comes as the output for the specified expression.

Example:

The below query gives the arc tangent value in the four quadrants of 0.

See the EMPLOYEES table, which has these records.

ID NAME AGE ADDRESS SALARY
01 William 32 Karachi 72000
02 Avery 24 London 34000
03 Jackson 34 Paris 12000
04 Harper 20 United state 15000
05 Ella 22 Islamabad 33000
06 Monty 23 Turkey 42000
07 Mason 26 Saudi 50500
  • BETWEEN ()

If the value exists between the two expressions, then the below output will come.

Where salary is between 20000 and 85000.

Output:

T-SQL Numeric function
  • MIN()

The minimum value will occur as the output from the given expression.

Example:

The query gives '15000.00' for the 'salary' expression from the Employee table.

  • MAX ()

The maximum value is returned as the output of the expression.

Example:

The below code will give '20000.00' for the 'salary' expression from the customer's table.

  • SQRT ()

The square root of the numeric expression is returned as the output.

Example

It gives 2 for the 4 numeric expressions.

  • PI()

The PI() function generates the numeric output.

Example:

The below query gives 3.14159265358979 for the PI value.

  • CEILING():

The CEILING () function returns the output after rounding of the decimals, which is the next highest value of the table.

Example:

The query gives 235 for the given 234.25 value.

  • FLOOR()

The function generates the output after rounding of the decimals, which is equal to or less than the expression value.

Example:

The query gives 231 for the given 231.34 value.

  • LOG ()

The natural logarithm of the expression is returned as the output.

Example:

The below query will give 0 for the given one value.






Help Others, Please Share

facebook twitter pinterest

Learn Latest Tutorials


Preparation


Trending Technologies


B.Tech / MCA