ONLINE HELP
 WINDEVWEBDEV AND WINDEV MOBILE

This content has been translated automatically.  Click here  to view the French version.
Help / Editors / Query editor / SQL
  • Overview
  • Mathematical SQL functions
  • ABS
  • ACOS
  • ASIN
  • ATAN
  • ATAN2
  • BIN
  • CAST
  • CBRT
  • CEILING
  • CEIL
  • COS
  • DEGREES
  • DIV
  • EXP
  • FLOOR
  • HEX
  • LN
  • LOG
  • LOG10
  • MOD
  • OCT
  • PI
  • POWER
  • RADIANS
  • RANDOM
  • ROUND
  • SIGN
  • SIN
  • SQRT
  • STDDEV
  • STDDEV_POP
  • STDDEV_SAMP
  • TAN
  • TRUNC
  • UNHEX
  • VARIANCE
  • VAR_POP
  • VAR_SAMP
WINDEV
WindowsLinuxJavaReports and QueriesUser code (UMC)
WEBDEV
WindowsLinuxPHPWEBDEV - Browser code
WINDEV Mobile
AndroidAndroid Widget iPhone/iPadIOS WidgetApple WatchMac Catalyst
Others
Stored procedures
Overview
The mathematical SQL functions that can be used on the queries written in SQL code are as follows:

For more details, see a specific documentation about the SQL language.
To discover all the SQL commands (functions, clauses, operators, etc.) that can be used in an SQL query managed by HFSQL, see Commands that can be used in an SQL query managed by HFSQL.
Remarks:
  • These statements can be used:
    • in the SQL code of queries created in the query editor. Then, these queries will be run by HExecuteQuery.
    • in the SQL code of queries run by HExecuteSQLQuery.
  • Unless stated otherwise, these functions can be used with all the types of data sources (Oracle, Access, SQL Server, and so on).
Mathematical SQL functions

ABS

ABS is used to find out the absolute value of a number.
Format:
ABS(Nombre)

ACOS

ACOS is used to find out the cosine angle of a number.
Use format:
ACOS(Nombre)

ASIN

ASIN is used to find out the sine angle of a number.
Format:
ASIN(Nombre)

ATAN

ATAN is used to find out the tangent angle of a number.
Format:
ATAN(Nombre)

ATAN2

ATAN2 is used to find out the arctangent of the X and Y variables. This function is equivalent to the calculation of the arctangent of Y/X except that the signs of the two arguments are used to define the quadrant of the result.
Format:
ATAN2(Y,X)

BIN

BIN returns the character string representing an "integer" in binary format. This integer must be found between 0 and 2 to the power of 63-1.
Native Connectors (Native Accesses) This function cannot be used on a PostgreSQL data source.
Format:
BIN(Entier)

CAST

CAST is used to convert a number into another one.
Format:
CAST(Nombre AS Type)
Use example:
  • Converts the GrandTotal(currency) into an integer (no decimal):
    CAST(commande.totalttc AS integer)
  • Convert the totalIOT (currency) into 6-digit numeric among which 2 digits for the decimal part.
    CAST(commande.totalttc AS decimal (6,2))

CBRT

CBRT returns the cube root of a number.
Format:
CBRT(Nombre)

CEILING

CEIL

CEILING and CEIL return the rounded-up value of a number.
Format:
CEILING(Nombre)
CEIL(Nombre)

COS

COS is used to find out the cosine of a number.
Format:
COS(Nombre)

DEGREES

DEGREES is used to convert an angle expressed in radians into degrees.
Format:
DEGREES(Nombre)

DIV

DIV performs a division
Format:
DIV(Dividende, Diviseur)

EXP

EXP is used to find out the exponential value of a number.
Format:
EXP(Nombre)

FLOOR

FLOOR is used to find out the rounded-down value of a number.
Format:
FLOOR(Nombre)

HEX

HEX returns the hexadecimal value of an integer (expressed in base 10). This integer must be found between 0 and 2 to the power of 63-1.
Note: Used with the HFSQL engine, the HEX function returns a string starting with the most significant byte.
Native Connectors (Native Accesses) Special cases:
  • Native Connector DB2: The HEX function used on Numericals returns a character string starting with the weak byte. .
  • Native Connector PostgreSQL: This function cannot be used on a PostgreSQL data source..
Format:
HEX(Entier)
HFSQL example: HEX(258) = 0102
Example on DB2: HEX(258) = 0201

LN

LN is used to find out the Napierian logarithm of a number.
Format:
LN(Nombre)

LOG

LOG is used to find out the Napierian logarithm of a number.
Format:
LOG(Nombre)
Other possible syntax: Logarithm in base Number base:
LOG(Base, Nombre)

LOG10

LOG10 is used to find out the decimal logarithm of a number.
Native Connectors (Native Accesses) This function cannot be used on a PostgreSQL data source.
Format:
LOG10(Nombre)

MOD

MOD is used to find out the remainder of a division between two numbers (modulo).
Format:
MOD(Dividende, Diviseur)

OCT

OCT returns an integer in octal (expressed in base 10). This integer must be found between 0 and 2 to the power of 63-1.
Native Connectors (Native Accesses) This function cannot be used on a PostgreSQL data source.
Format:
OCT(Entier)

PI

PI is used to find out the value of PI.
Format:
PI()

POWER

POWER is used to find out the value of a number raised to a power.
Format:
POWER(Nombre, Puissance)

RADIANS

RADIANS converts an angle expressed in degrees into radians.
Format:
RADIANS(Nombre)

RANDOM

RANDOM returns a number included between 0.0 and 1.0 (inclusive).
The RAND function is equivalent: it returns a number between 0.0 and 1.0 (inclusive).
Format:
  • RANDOM:
    RANDOM()
  • RAND:
    RAND()

ROUND

ROUND is used to round up a number according to the number of decimal places.
Format:
ROUND(Nombre, Décimal)
Example: The following SQL code rounds product prices to 2 decimal places:
SELECT Désignation,
ROUND(PrixHT, 2) AS Prix
FROM PRODUIT

SIGN

SIGN returns 1, 0 or -1 depending on whether the given number is positive, null or negative.
Format:
SIGN(Nombre)

SIN

SIN is used to find out the sine of a number.
Format:
SIN(Nombre)
Note: The Number parameter is expressed in radians..

SQRT

SQRT is used to find out the square root of a number.
Format:
SQRT(Nombre)

STDDEV

STDDEV is used to find out the standard deviation for a series of values. STDDEV is used when the series of values represents a sample of the data population. This function is equivalent to STDDEV_SAMP.
The standard deviation is the square root of the variance.
Format:
STDDEV(Nombre)
Example: Mean and standard deviation of TotalIOT for the orders per year:
SELECT SUBSTR(commande.datecommande,1,4) AS annee, AVG(commande.totalttc) AS moyenne,
STDDEV (commande.totalttc) AS unecarttype FROM commande GROUP BY annee

STDDEV_POP

STDDEV_POP is used to find out the standard deviation for a series of values. STDDEV_POP is used when the series of values represents the entire data population.
The standard deviation is the square root of the variance.
Format:
STDDEV_POP(Nombre)
Example: Mean and standard deviation of TotalIOT for the orders per year:
SELECT SUBSTR(commande.datecommande,1,4) AS annee, AVG(commande.totalttc) AS moyenne,
STDDEV_POP (commande.totalttc) AS unecarttype FROM commande GROUP BY annee

STDDEV_SAMP

STDDEV_SAMP is used find out the standard deviation for a series of values. STDDEV_SAMP is used when the series of values represents a sample of the data population. This function is equivalent to STDDEV.
The standard deviation is the square root of the variance.
Format:
STDDEV_SAMP(Nombre)
Example: Mean and standard deviation of TotalIOT for the orders per year:
SELECT SUBSTR(commande.datecommande,1,4) AS annee, AVG(commande.totalttc) AS moyenne,
STDDEV_SAMP (commande.totalttc) AS unecarttype FROM commande GROUP BY annee

TAN

TAN is used to find out the tangent of a number.
Format:
TAN(Nombre)

TRUNC

TRUNC is used to find out the integer part.
Format:
TRUNC(Nombre)

UNHEX

UNHEX performs the reverse operation of HEX. Each pair of hexadecimal digits:
  • is interpreted as numbers.
  • is converted into a character represented by the number.
The returned value is a binary string.
Format:
UNHEX(Chaîne hexadécimale)
Note: If the characters passed to the function do not correspond to elements of a hexadecimal value, the function returns NULL..

VARIANCE

VARIANCE is used to find out the variance for a series of values. VARIANCE is used when the series of values represents a sample of the data population. This function is equivalent to VAR_SAMP.
Format:
VARIANCE(Nombre)
Example: Mean and variance of TotalIOT for the orders per year:
SELECT SUBSTR(commande.datecommande,1,4) AS annee, AVG(commande.totalttc) AS moyenne,
VARIANCE (commande.totalttc) AS mavariance FROM commande GROUP BY annee

VAR_POP

VAR_POP is used to find out the variance for a series of values. VAR_POP is used when the series of values represents the entire data population.
Format:
VAR_POP(Nombre)
Example: Mean and variance of TotalIOT for the orders per year:
SELECT SUBSTR(commande.datecommande,1,4) AS annee, AVG(commande.totalttc) AS moyenne,
VAR_POP (commande.totalttc) AS mavariance FROM commande GROUP BY annee

VAR_SAMP

VAR_SAMP is used to find out the standard deviation for a series of values. VAR_SAMP is used when the series of values represents a sample of the data population. This function is equivalent to VARIANCE.
The standard deviation is the square root of the variance.
Format:
VAR_SAMP(Nombre)
Example: Mean and variance of TotalIOT for the orders per year:
SELECT SUBSTR(commande.datecommande,1,4) AS annee, AVG(commande.totalttc) AS moyenne,
VAR_SAMP (commande.totalttc) AS mavariance FROM commande GROUP BY annee
Minimum version required
  • Version 9
This page is also available for…
Comments
Click [Add] to post a comment

Last update: 09/14/2024

Send a report | Local help