GREATESTB

Returns its greatest argument, using binary ordering, not UTF-8 character ordering.

Behavior Type

Immutable

Syntax

GREATESTB ( expression1, expression2, ... expression-n )

Parameters

expression1, expression2, and expression-n are the expressions to be evaluated.

Notes

Examples

The following command selects straße as the greatest in the series of inputs:

=> SELECT GREATESTB('straße', 'strasse');
 GREATESTB
-----------
 straße
(1 row) 

This example returns 9 as the greatest in the list of expressions:

=> SELECT GREATESTB(7, 5, 9);
 GREATESTB
-----------
         9
(1 row)

Note that putting quotes around the integer expressions returns the same result as the first example:

=> SELECT GREATESTB('7', '5', '9');
 GREATESTB
-----------
 9
(1 row)

The next example returns FLOAT 1.5 as the greatest because the integer is implicitly cast to float:

=> SELECT GREATESTB(1, 1.5);
 GREATESTB
-----------
       1.5
(1 row)

The following example returns vertica as the greatest:

=> SELECT GREATESTB('vertica', 'analytic', 'database');
  GREATESTB
-----------
 vertica
(1 row)

Notice this next command returns NULL:

=> SELECT GREATESTB('vertica', 'analytic', 'database', null);
 GREATESTB
-----------
(1 row)

And one more:

=> SELECT GREATESTB('sit', 'site', 'sight');
 GREATESTB
-----------
 site
(1 row)

See Also