minimum()#

relationalai.std
#minimum(arg1: Any, arg2: Any, *args: Any) -> Expression

Returns the minimum of the arguments. Must be used in a rule or query context.

Parameters#

NameTypeDescription
arg1AnyThe first argument.
arg2AnyThe second argument.
*argsAnyAdditional arguments.

Returns#

An Expression object.

Example#

Use minimum() to return the minimum of two or more arguments:

#import relationalai as rai
from relationalai.std import alias, minimum

model = rai.Model("MyModel")
Point = model.Type("Point")

with model.rule():
    Point.add(x=1, y=2)
    Point.add(x=4, y=3)

with model.query() as select:
    point = Point()
    min_coord = minimum(point.x, point.y)
    response = select(point.x, point.y, alias(min_coord, "min"))

print(response.results)
#    x  y  min
# 0  1  2    1
# 1  4  3    3

See Also#