AbsDB SQL Mathematical Functions

<< Click to Display Table of Contents >>

Navigation:  SQL Reference Absolute Database >

AbsDB SQL Mathematical Functions

Previous pageReturn to chapter overviewNext page

Math Functions

Absolute Database supports the following mathematical functions:

Function

Description

ABS

Returns the absolute value of a number

ACOS

Returns the inverse cosine of a given number

ASIN

Returns the inverse sine of a given number

ATAN

Returns the arctangent of a number

CEIL

Rounds variables up toward positive infinity

COS

Returns the cosine of an angle

EXP

Returns the exponential of a number

FLOOR

Rounds variables toward negative infinity

LOG

Returns the natural log of a real expression

POWER

Raises Base to any power

RAND

Generates random numbers within a specified range

ROUND

Returns the value of a number rounded to the specified length or precision.

SIGN

Indicates whether a numeric value is positive, negative, or zero

SIN

Returns the sine of the angle in radians

SQR

Returns the square of a number

SQRT

Returns the square root of a number

 

ABS (numeric_exp)

Returns the absolute value of a number.

Example:

 ABS(-2.9) returns 2.9

 

ACOS (numeric_exp)

Returns the inverse cosine of a given number.

Example:

 ACOS(1) returns 0

 

ASIN (numeric_exp)

Returns the inverse sine of a given number.

Example:

 ASIN(0) returns 0

 

ATAN (numeric_exp)

Returns the arctangent of a number.

Example:

 ATAN(0) returns 0

 

CEIL (numeric_exp)

The ceil function returns the smallest integer value that is greater than or equal to a number.

Example:

 CEIL(11.22) returns 12

 

COS (numeric_exp)

The cos function returns the cosine of a number.

Example:

 COS(-3.15) returns -0.999964658471342

 

EXP (numeric_exp)

The exp function returns e raised to the nth power, where e = 2.71828183.

Example:

 EXP(3) returns 20.0855369231877

 

FLOOR (numeric_exp)

The floor function returns the largest integer value that is equal to or less than a number.

Example:

 FLOOR(3.67) returns 3

 

LOG (numeric_exp)

The log function returns the natural logarithm of a number.

Example:

 LOG(20) returns 2.99573227355399

Note:
At denne funktion returnerer den naturlige logaritme, vil sikkert undre nogen, men denne funktionalitet er faktisk standarden indenfor SQL, hvor 10-tals (Briggs') logaritme funktionen i de SQL-implementeringer, der inkluderer denne, har formen LOG10(numeric_expression).

 

POWER (base, exponent)

The power function returns base raised to the exponent power.

Example:

 POWER(3,2) returns 9

 

RAND (numeric_exp)

Returns a string equal to that in numeric_exp with all uppercase characters converted to lowercase.

Example:

 RAND(10) may return 0..9

 

ROUND (numeric_exp, [ decimals = 0 [, rounding_mode = HalfEven ] ])

The round function returns a number rounded to the specified length or precision.

The decimals parameter is the precision to which numeric_exp is to be rounded

The rounding_mode possible values are:

HalfEven - Round to nearest or to even whole number. ("Banker's Rounding")
HalfPos - Round to nearest or toward positive.
HalfNeg - Round to nearest or toward negative.
HalfDown - Round to nearest or toward zero.
HalfUp - Round to nearest or away from zero.
RndNeg - Round toward negative. (i.e. Floor)
RndPos - Round toward positive. (i.e. Ceil)
RndDown - Round toward zero. (i.e. Trunc)
RndUp - Round away from zero.

Example:

ROUND(4.6) returns 5
ROUND(4.56, 1) returns 4.6
ROUND(1.235, 2) returns 1.24
ROUND(1.245, 2) returns 1.24
ROUND(1.245, 2, HalfPos) returns 1.25

ROUND (numeric_exp)

The round function returns a number rounded to the nearest whole number.

Example:

 ROUND(4.6) returns 5

Note:
Funktionen ROUND er ikke defineret i ISO-SQL, og funktionen er ret forskelligt implementeret i diverse databasesystemer og derfor ikke særligt portabel.
I Absolute Database svarer default funktionaliteten af ROUND til den såkaldte "Banker's Rounding", der modsat vanlig matematisk afrunding runder nedad til nærmeste lige heltal, hvis tallet er et lige tal + 0.5, hvorved f.eks. hhv. ROUND(0.5), ROUND(1.5) og ROUND(2.5) giver værdierne 0, 2 og 2 respektivt, mens ROUND(0.51) og ROUND(2.51) giver hhv. 1 og 3.

 

SIGN (numeric_exp)

The sign function returns a value indicating the sign of a number.

Example:

 SIGN(10) returns 1

 

SIN (numeric_exp)

The sin function returns the sine of a number.

Example:

 SIN(3) returns 0.141120008059867

 

SQR (numeric_exp)

Returns the square of a number.

Example:

 SQR(3) returns 9

 

SQRT (numeric_exp)

The sqrt function returns the square root of a number.

Example:

 SQRT(9) returns 3

_____________________________

27-10-2017 - Niels Knabe