min()

Returns the smallest value among the provided arguments.

Syntax

min(EXPR1[, EXPR2, ...])

Parameters

EXPR1, EXPR2, ...
Value expressions to compare. One or more arguments can be specified.

Description

The min() function accepts one or more arguments and returns the smallest value among them. Comparison uses Logpresso's internal object comparator, which supports various types including numbers, strings, and timestamps.

Null values are excluded from comparison. Returns null if all arguments are null.

This function is a scalar expression function, not an aggregate function. Use it in the eval command to compare values row by row. For the aggregate version, refer to the min aggregate function.

Error codes

N/A

Usage examples

To prepare the WEB_APACHE_SAMPLE table used in these examples, refer to Preparing sample data.

  1. Return the smaller of the request size and an upper bound.

    table limit=5 WEB_APACHE_SAMPLE | eval result = min(bytes, 1024)
    | fields bytes, result
    
  2. Return the smallest value among string arguments.

    json "{}" | eval m = min("b", "a", "c")
    | # m: a
    
  3. NULL input — returns null when all arguments are null.

    json "{}" | eval m = min(null, null)
    | # m: null
    

Compatibility

The min() function is available since before Sonar 4.0.