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.

IDNAMEAGEADDRESSSALARY
01William32Karachi72000
02Avery24London34000
03Jackson34Paris12000
04Harper20United state15000
05Ella22Islamabad33000
06Monty23Turkey42000
07Mason26Saudi50500
  • 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.