YMatrix
Quick Start
Connecting
Benchmarks
Deployment
Data Usage
Manage Clusters
Upgrade
Global Maintenance
Expansion
Monitoring
Security
Best Practice
Technical Principles
Data Type
Storage Engine
Execution Engine
Streaming Engine(Domino)
MARS3 Index
Extension
Advanced Features
Advanced Query
Federal Query
Grafana
Backup and Restore
Disaster Recovery
Graph Database
Introduction
Clauses
Functions
Advanced
Guide
Performance Tuning
Troubleshooting
Tools
Configuration Parameters
SQL Reference
rand()rand() returns a pseudo-random floating-point number in the range [0.0, 1.0), i.e., inclusive of 0.0 and exclusive of 1.0. The returned values approximate a uniform distribution.
Syntax: rand()
Returns:
A floating-point number.
Query:
SELECT *
FROM cypher('graph_name', $$
RETURN rand()
$$) as (random_number agtype);
Returns a random number.
Result:
| random_number |
|---|
| 0.3586784748902053 |
| 1 row |
abs()abs() returns the absolute value of a given number.
Syntax: abs(expression)
Returns:
The result has the same type as `expression`.
Parameters:
| Name | Description |
|---|---|
expression |
An agtype numeric expression. |
Notes:
abs(null) returns null.expression is negative, abs() returns -(expression) — the additive inverse.Query:
SELECT *
FROM cypher('graph_name', $$
MATCH (a), (e) WHERE a.name = 'Alice' AND e.name = 'Eskil'
RETURN a.age, e.age, abs(a.age - e.age)
$$) as (alice_age agtype, eskil_age agtype, difference agtype);
Returns the absolute difference between the two ages.
Result:
| alice_age | eskil_age | difference |
|---|---|---|
| 38 | 41 | 3 |
| 1 row |
ceil()ceil() returns the smallest floating-point number that is greater than or equal to the given number and is mathematically an integer.
Syntax: ceil(expression)
Returns:
A floating-point number.
Parameters:
| Name | Description |
|---|---|
expression |
An agtype numeric expression. |
Notes:
ceil(null) returns null.Query:
SELECT *
FROM cypher('graph_name', $$
RETURN ceil(0.1)
$$) as (ceil_value agtype);
Returns the ceiling of 0.1.
Result:
| ceil_value |
|---|
| 1 |
| 1 row |
floor()floor() returns the largest floating-point number that is less than or equal to the given number and is mathematically an integer.
Syntax: floor(expression)
Returns:
A floating-point number.
Parameters:
| Name | Description |
|---|---|
expression |
An agtype numeric expression. |
Notes:
floor(null) returns null.Query:
SELECT *
FROM cypher('graph_name', $$
RETURN floor(0.1)
$$) as (flr agtype);
Returns the floor of 0.1.
Result:
| flr |
|---|
| 0 |
| 1 row |
round()round() returns the nearest integer to the given number, rounded to the closest whole number.
Syntax: round(expression)
Returns:
A floating-point number.
Parameters:
| Name | Description |
|---|---|
expression |
An agtype numeric expression. |
Notes:
round(null) returns null.Query:
SELECT *
FROM cypher('graph_name', $$
RETURN round(3.141592)
$$) as (rounded_value agtype);
Returns 3.0.
Result:
| rounded_value |
|---|
| 3.0 |
| 1 row |
sign()sign() returns the sign of a given number: 0 if the number is zero, -1 for any negative number, and 1 for any positive number.
Syntax: sign(expression)
Returns:
An integer.
Parameters:
| Name | Description |
|---|---|
expression |
An agtype numeric expression. |
Notes:
sign(null) returns null.Query:
SELECT *
FROM cypher('graph_name', $$
RETURN sign(-17), sign(0.1), sign(0)
$$) as (negative_sign agtype, positive_sign agtype, zero_sign agtype);
Returns the sign values for -17 and 0.1.
Result:
| negative_sign | positive_sign | zero_sign |
|---|---|---|
| -1 | 1 | 0 |
| 1 row |