Math Function in SQL Server

Vaishali Goilkar
1 min readMay 27, 2020

In this article, we learn about Math Functions in SQL Server.

ABS

  • The ABS() function returns the absolute value of a number.
  • Syntax: ABS(number)

AVG

  • The AVG() function returns the average value of an expression.
  • NULL values are ignored.
  • Syntax: AVG(expression)

CEILING

  • The CEILING() function returns the smallest integer value that is larger than or equal to a number.
  • Syntax: CEILING(number)

COUNT

  • The COUNT() function returns the number of records returned by a select query.
  • NULL values are not counted.
  • Syntax: COUNT(expression)

FLOOR

  • The FLOOR() function returns the largest integer value that is smaller than or equal to a number.
  • Syntax: FLOOR(number)

MAX

  • The MAX() function returns the maximum value in a set of values.
  • Syntax: MAX(expression)

MIN

  • The MIN() function returns the minimum value in a set of values
  • Syntax: MIN(expression)

RAND

  • The RAND() function returns a random number between 0 and 1.
  • If the seed is specified, it returns a repeatable sequence of random numbers.
  • If no seed is specified, it returns a completely random number.
  • Syntax: RAND(seed)

ROUND

  • The ROUND() function rounds a number to a specified number of decimal places.
  • Syntax: ROUND(number, decimals, operation)

SIGN

  • The SIGN() function returns the sign of a number.

If number > 0, it returns 1

If number = 0, it returns 0

If number < 0, it returns -1

  • Syntax: SIGN(number)

SUM

  • The SUM() function calculates the sum of a set of values.
  • Syntax: SUM(expression)

If you are a newbie to database learning — SQL Server recommended is the following must-watch video: -

--

--