A RetroSearch Logo

Home - News ( United States | United Kingdom | Italy | Germany ) - Football scores

Search Query:

Showing content from https://docs.snowflake.com/en/sql-reference/functions/greatest below:

Website Navigation


GREATEST | Snowflake Documentation

Categories:

Conditional expression functions

GREATEST

Returns the largest value from a list of expressions. GREATEST supports all data types, including VARIANT.

See also:

GREATEST_IGNORE_NULLS

Syntax
GREATEST( <expr1> [ , <expr2> ... ] )

Copy

Arguments
exprN

The arguments must include at least one expression. All the expressions should be of the same type or compatible types.

Returns

The first argument determines the return type:

If any argument is NULL, returns NULL.

Collation details Examples

The following examples use the GREATEST function:

CREATE TABLE test_table_1_greatest (
  col_1 INTEGER, 
  col_2 INTEGER, 
  col_3 INTEGER, 
  col_4 FLOAT);
INSERT INTO test_table_1_greatest (col_1, col_2, col_3, col_4) VALUES
  (1, 2,    3,  4.00),
  (2, 4,   -1, -2.00),
  (3, 6, NULL, 13.45);

Copy

SELECT col_1,
       col_2,
       col_3,
       GREATEST(col_1, col_2, col_3) AS greatest
  FROM test_table_1_greatest
  ORDER BY col_1;

Copy

+-------+-------+-------+----------+
| COL_1 | COL_2 | COL_3 | GREATEST |
|-------+-------+-------+----------|
|     1 |     2 |     3 |        3 |
|     2 |     4 |    -1 |        4 |
|     3 |     6 |  NULL |     NULL |
+-------+-------+-------+----------+
SELECT col_1,
       col_4,
       GREATEST(col_1, col_4) AS greatest
  FROM test_table_1_greatest
  ORDER BY col_1;

Copy

+-------+-------+----------+
| COL_1 | COL_4 | GREATEST |
|-------+-------+----------|
|     1 |  4    |     4    |
|     2 | -2    |     2    |
|     3 | 13.45 |    13.45 |
+-------+-------+----------+

RetroSearch is an open source project built by @garambo | Open a GitHub Issue

Search and Browse the WWW like it's 1997 | Search results from DuckDuckGo

HTML: 3.2 | Encoding: UTF-8 | Version: 0.7.4