rand

rand() returns a random floating point number in the range from 0 (inclusive) to 1 (exclusive); i.e.[0,1). The numbers returned follow an approximate uniform distribution.

Syntax: rand()

Returns:

  1. A float.

Query:

  1. SELECT *
  2. FROM cypher('graph_name', $$
  3. RETURN rand()
  4. $$) as (random_number agtype);

A random number is returned.

Result:

random_number
0.3586784748902053
1 row(s) returned

abs

abs() returns the absolute value of the given number.

Syntax: abs(expression)

Returns:

  1. The type of the value returned will be that of expression.

Arguments:

Name Description
expression An agtype number expression

Considerations:

  • abs(null) returns null.
  • If expression is negative, -(expression) (i.e. the negation of expression) is returned.

Query:

  1. SELECT *
  2. FROM cypher('graph_name', $$
  3. MATCH (a), (e) WHERE a.name = 'Alice' AND e.name = 'Eskil'
  4. RETURN a.age, e.age, abs(a.age - e.age)
  5. $$) as (alice_age agtype, eskil_age agtype, difference agtype);

The absolute value of the age difference is returned.

Result:

alice_age eskil_age difference
38 41 3
1 row(s) returned

ceil

ceil() returns the smallest floating point number that is greater than or equal to the given number and equal to a mathematical integer.

Syntax: ceil(expression)

Returns:

  1. A float.

Arguments:

Name Description
expression An agtype number expression

Considerations:

  • ceil(null) returns null.

Query:

  1. SELECT *
  2. FROM cypher('graph_name', $$
  3. RETURN ceil(0.1)
  4. $$) as (ceil_value agtype);

The ceiling of 0.1 is returned.

Result:

ceil_value
1
1 row(s) returned

floor

floor() returns the greatest floating point number that is less than or equal to the given number and equal to a mathematical integer.

Syntax: floor(expression)

Returns:

  1. A float.

Arguments:

Name Description
expression An agtype number expression

Considerations:

  • floor(null) returns null.

Query:

  1. SELECT *
  2. FROM cypher('graph_name', $$
  3. RETURN floor(0.1)
  4. $$) as (flr agtype);

The floor of 0.1 is returned.

Result:

flr
0
1 row(s) returned

round

round() returns the value of the given number rounded to the nearest integer.

Syntax: round(expression)

Returns:

  1. A float.

Arguments:

Name Description
expression An agtype number expression

Considerations:

  • round(null) returns null.

Query:

  1. SELECT *
  2. FROM cypher('graph_name', $$
  3. RETURN round(3.141592)
  4. $$) as (rounded_value agtype);

3.0 is returned.

Result:

rounded_value
3.0
1 row(s) returned

sign

sign() returns the signum of the given number: 0 if the number is 0, -1 for any negative number, and 1 for any positive number

Syntax: sign(expression)

Returns:

  1. An integer.

Arguments:

Name Description
expression An agtype number expression

Considerations:

  • sign(null) returns null.

Query:

  1. SELECT *
  2. FROM cypher('graph_name', $$
  3. RETURN sign(-17), sign(0.1), sign(0)
  4. $$) as (negative_sign agtype, positive_sign agtype, zero_sign agtype);

The signs of -17 and 0.1 are returned.

Result:

negative_sign positive_sign zero_sign
-1 1 0
1 row(s) returned