GREATEST Function Examples | Teradata Vantage - 17.10 - Examples - Advanced SQL Engine - Teradata Database

Teradata Vantageā„¢ - SQL Functions, Expressions, and Predicates

Product
Advanced SQL Engine
Teradata Database
Release Number
17.10
Published
July 2021
Language
English (United States)
Last Update
2021-07-28
dita:mapPath
SQL_Functions__Expressions__and_Predicates.Upload_071421/djk1612415574830.ditamap
dita:ditavalPath
SQL_Functions__Expressions__and_Predicates.Upload_071421/wrg1590696035526.ditaval
dita:id
kby1472250656485

Example: Querying for the Largest Integer Value

The following query returns the result 13.

   SELECT GREATEST(13, 6);

Example: GREATEST with DECIMAL Input

In the following query, if the input arguments have data types of DECIMAL(4,2) and DECIMAL(5,4), the return data type is DECIMAL(6,4) and the result value is 13.1200.

   SELECT GREATEST(13.12, 6.1234); 

Example: GREATEST with Character Input

The following query returns the result 'apples'.

   SELECT GREATEST('apples', 'alpha');

Example: Comparing Milliseconds in a TIMESTAMP

SELECT GREATEST('2003-08-17 12:15:24.756' (TIMESTAMP(6)), '2003-08-17 12:15:24.456' (TIMESTAMP(6)));

Result:

greatest('2003-08-17 12:15:24.756','2003-08-17 12:15:24.456')
-------------------------------------------------------------
                                   2003-08-17 12:15:24.756000