MySQL: GREATEST Function

  • Post author:
  • Post category:MySQL
  • Post comments:1 Comment
MySQL GREATEST Function

In this guide, we will explain how to use the MySQL GREATEST function with syntax and examples.

Description

The MySQL GREATEST function returns the greatest value in a list of expressions.

Syntax

The syntax for the GREATEST function inis:

GREATEST( expr1, expr2, ... expr_n )

Parameters or Arguments

expr1, expr2, … expr_n

The expressions that are evaluated by the GREATEST function.

Applies To

The GREATEST function can be used in the following versions :

  • MySQL 5.7, MySQL 5.6, MySQL 5.5, MySQL 5.1, MySQL 5.0, MySQL 4.1, MySQL 4.0, MySQL 3.23

Example

Let’s look at some GREATEST function examples and explore how to use the GREATEST function.

For example:

mysql> SELECT GREATEST(2, 5, 12, 3);
Result: 12

mysql> SELECT GREATEST('2', '5', '12', '3');
Result: '5'

mysql> SELECT GREATEST('adglob.in', 'baldevinfo.com', 'adglob.in/blog/');
Result: 'adglob.in'

mysql> SELECT GREATEST('adglob.in', 'baldevinfo.com', null);
Result: NULL

Next Topic : Click Here

This Post Has One Comment

Leave a Reply