All Products
Search
Document Center

MaxCompute:ARRAY_MIN

Last Updated:Jul 24, 2023

Returns the smallest element in Array a.

Syntax

T array_min(array<T> <a>) 

Parameters

a: required. This parameter specifies an array. T in array<T> specifies the data type of the elements in the array.

The following data types are supported:
  • TINYINT, SMALLINT, INT, and BIGINT
  • FLOAT and DOUBLE
  • BOOLEAN
  • DECIMAL and DECIMALVAL
  • DATE, DATETIME, TIMESTAMP, IntervalDayTime, and IntervalYearMonth
  • STRING, BINARY, VARCHAR, and CHAR
  • ARRAY, STRUCT, and MAP

Return value

The smallest element in Array a is returned. The return value varies based on the following rules:

  • If Array a is null, the return value is null.

  • If an element in Array a is null, the null element is not involved in the operation.

Examples

-- The return value is 1. 
select array_min(array(1, 20, null, 3));

Related functions

ARRAY_MIN is a complex type function. For more information about functions that are used to process data of complex data types, such as ARRAY, MAP, STRUCT, and JSON, see Complex type functions.