0% found this document useful (0 votes)
2 views3 pages

Essential SQL Numeric Functions Guide

The document provides a comprehensive overview of various numeric functions available in SQL, including their purpose and example usage. Functions such as ABS(), AVG(), COUNT(), and SUM() are highlighted for their ability to perform calculations like absolute value, average, counting rows, and summing values. Additionally, trigonometric functions like SIN(), COS(), and TAN() are included, along with logarithmic and rounding functions.

Uploaded by

shrutikarpe2000
Copyright
© All Rights Reserved
We take content rights seriously. If you suspect this is your content, claim it here.
Available Formats
Download as PDF, TXT or read online on Scribd
0% found this document useful (0 votes)
2 views3 pages

Essential SQL Numeric Functions Guide

The document provides a comprehensive overview of various numeric functions available in SQL, including their purpose and example usage. Functions such as ABS(), AVG(), COUNT(), and SUM() are highlighted for their ability to perform calculations like absolute value, average, counting rows, and summing values. Additionally, trigonometric functions like SIN(), COS(), and TAN() are included, along with logarithmic and rounding functions.

Uploaded by

shrutikarpe2000
Copyright
© All Rights Reserved
We take content rights seriously. If you suspect this is your content, claim it here.
Available Formats
Download as PDF, TXT or read online on Scribd

Numeric Functions in SQL

ABS()
Returns the absolute (positive) value.
SELECT ABS(-25) AS AbsoluteValue;

ACOS()
Returns arc cosine (inverse cosine) in radians.
SELECT ACOS(0.5) AS ArcCosine;

ASIN()
Returns arc sine (inverse sine) in radians.
SELECT ASIN(0.5) AS ArcSine;

ATAN()
Returns arc tangent (inverse tangent) in radians.
SELECT ATAN(1) AS ArcTangent;

ATN2(y, x)
Returns angle between x and y coordinates (in radians).
SELECT ATN2(2, 3) AS Angle;

AVG()
Returns average of column values.
SELECT AVG(salary) AS AvgSalary FROM employees;

CEILING()
Returns smallest integer greater than or equal to number.
SELECT CEILING(12.34) AS CeilValue;

COUNT()
Returns count of rows.
SELECT COUNT(*) AS TotalEmployees FROM employees;

COS()
Returns cosine of an angle (radians).
SELECT COS(0) AS CosValue;

COT()
Returns cotangent of an angle.
SELECT COT(1) AS CotValue;
DEGREES()
Converts radians to degrees.
SELECT DEGREES(PI()/2) AS DegreesValue;

EXP()
Returns e^x (exponential value).
SELECT EXP(1) AS ExponentialValue;

FLOOR()
Returns largest integer less than or equal to number.
SELECT FLOOR(12.75) AS FloorValue;

LOG()
Returns natural logarithm (base e).
SELECT LOG(10) AS NaturalLog;

LOG10()
Returns logarithm base 10.
SELECT LOG10(100) AS Log10Value;

MAX()
Returns maximum value in column.
SELECT MAX(salary) AS HighestSalary FROM employees;

MIN()
Returns minimum value in column.
SELECT MIN(salary) AS LowestSalary FROM employees;

PI()
Returns value of π.
SELECT PI() AS PiValue;

POWER(x, y)
Returns x raised to power y.
SELECT POWER(2, 3) AS PowerValue;

RADIANS()
Converts degrees to radians.
SELECT RADIANS(180) AS RadianValue;
RAND()
Returns random value between 0 and 1.
SELECT RAND() AS RandomValue;

ROUND(x, d)
Rounds a number to d decimal places.
SELECT ROUND(123.4567, 2) AS RoundedValue;

SIGN()
Returns sign of number (-1, 0, 1).
SELECT SIGN(-25), SIGN(0), SIGN(30);

SIN()
Returns sine of angle (in radians).
SELECT SIN(PI()/2) AS SineValue;

SQRT()
Returns square root.
SELECT SQRT(16) AS SqrtValue;

SQUARE()
Returns square of number.
SELECT SQUARE(5) AS SquareValue;

SUM()
Returns sum of column values.
SELECT SUM(salary) AS TotalSalary FROM employees;

TAN()
Returns tangent of an angle (in radians).
SELECT TAN(PI()/4) AS TanValue;

You might also like