Skip to main content

PQL47 (PQL Function Library - CPM 4.7)

DIV

Applies to: CELONIS 4.0 CELONIS 4.2 CELONIS 4.3 CELONIS 4.4 CELONIS 4.5 CELONIS 4.6 CELONIS 4.7

Description

The division operator computes the quotient of two values.

The division operator can be applied to INT or FLOAT columns or constants. The data type of the result is always a FLOAT (Since: CELONIS 4.5). If the values of the second input column or constant (the divisor) is 0 (division by zero), the resulting value is set to null.

Syntax
DIV ( table.column1 , table.column2 )
table.column1 / table.column2
NULL handling

If one of the input values is NULL, the result is NULL as well.

Examples

[1] Divide a column of type INT by a constant INT value.

Query

Column1

"Table1"."Column1" / 10

Input

Output

Table1

Column1 : INT

10

20

30

40

Result

Column1 : FLOAT

1.0

2.0

3.0

4.0

[2] Divide a column of type FLOAT by a constant FLOAT value.

Query

Column1

"Table1"."Column1" / 10.0

Input

Output

Table1

Column1 : FLOAT

10.0

20.0

30.0

40.0

Output

Column1 : FLOAT

1.0

2.0

3.0

4.0

[3] Divide a column of type INT by a constant FLOAT value.

Query

Column1

"Table1"."Column1" / 10

Input

Output

Table1

Column1 : FLOAT

10.0

20.0

30.0

40.0

Result

Column1 : FLOAT

1.0

2.0

3.0

4.0

[4] Divide a column of type INT by a constant INT value. Note, that the division by zero for the second and third row does not result in an error, but returns null.

Query

Column1

"Table1"."Column1" / "Table1"."Column2"

Input

Output

Table1

Column1 : INT

Column2 : INT

10

10

20

0

30

0

40

10

Result

Column1 : FLOAT

1.0

null

null

4.0

[5] Divide values of multiple INT and FLOAT columns.

Query

Column1

"Table1"."IntColumn1" / "Table1"."IntColumn2"

Column2

DIV ( "Table1"."IntColumn1" , "Table1"."FloatColumn1" )

Column3

"Table1"."FloatColumn1" / "Table1"."FloatColumn2"

Column4

"Table1"."IntColumn1" / "Table1"."IntColumn2" / "Table1"."FloatColumn1"

Column5

DIV ( "Table1"."IntColumn1" , "Table1"."IntColumn2" / "Table1"."FloatColumn1" )

Input

Output

Table1

IntColumn1 : INT

IntColumn2 : INT

FloatColumn1 : FLOAT

FloatColumn2 : FLOAT

20

5

10.0

20.0

30

15

14.0

7.0

40

null

12.0

22.0

50

30

null

23.0

null

45

14.0

null

Result

Column1 : FLOAT

Column2 : FLOAT

Column3 : FLOAT

Column4 : FLOAT

Column5 : FLOAT

4.0

2.0

0.5

0.4

40.0

2.0

2.142857142857143

2.0

0.14285714285714285

28.0

null

3.3333333333333335

0.5454545454545454

null

null

1.6666666666666667

null

null

null

null

null

null

null

null

null