ANY
Purpose
This function returns TRUE if the value expr is true for at least one row in the window or group of input rows. Otherwise, this function returns FALSE.
Syntax
any::=
Usage Notes
- This function returns the value
NULLif the window of rows is empty. - It only accepts an operand of type
bool. DISTINCThas no effect.
Examples
Aggregate Function
SELECT
department,
ANY(age < 30) ANY_
FROM employee_table GROUP BY department;
Result
| DEPARTMENT | ANY |
| ACCOUNTS | true |
| HR | false |
Analytic Functions
SELECT
id, department, age,
ANY(age < 30) OVER (PARTITION BY department ORDER BY age) ANY_
FROM employee_table ORDER BY department, age;
Result
| ID | DEPARTMENT | AGE | ANY |
| 2003 | ACCOUNTS | 27 | true |
| 2001 | ACCOUNTS | 30 | true |
| 2002 | ACCOUNTS | 32 | true |
| 2004 | ACCOUNTS | 42 | true |
| 2005 | ACCOUNTS | 42 | true |
| 1001 | HR | 30 | false |
| 1004 | HR | 30 | false |
| 1002 | HR | 34 | false |
| 1003 | HR | 40 | false |