共用方式為


any 聚合函數

適用於:勾選是Databricks SQL 勾選是Databricks Runtime

如果群組中至少有一個 值true為 true,則傳expr回 。 any聚合函數與max聚合函數同義,但限於布林參數。 這個函數也是彙總函數的同義bool_or詞。

語法

any(expr) [FILTER ( WHERE cond ) ]

您也可以使用 子句將此函數作為 OVER 來調用。

引數

  • exprBOOLEAN 運算式。
  • cond:選擇性 BOOLEAN 表達式,篩選用於匯總的數據列。

退貨

BOOLEAN

範例

> SELECT any(col) FROM VALUES (true), (false), (false) AS tab(col);
 true

> SELECT any(col) FROM VALUES (NULL), (true), (false) AS tab(col);
 true

> SELECT any(col) FROM VALUES (false), (false), (NULL) AS tab(col);
 false

> SELECT any(col1) FILTER (WHERE col2 = 1)
    FROM VALUES (false, 1), (false, 2), (true, 2), (NULL, 1) AS tab(col1, col2);
 false