©SQL :: Manager
HomeProgram InformationTechnical detailsFree downloadDonate for a cup of coffee
myway SQL Manager for MySQL and MariaDB, Download on Uptodown
SQL functionMySQLMariaDB

The LEAST SQL Function in MySQL and MariaDB - Smallest value from list

LEASTSyntax:LEAST(%, %)
Return value:Depending on the data types used
Function type:Comparison function
Function Description

The LEAST() function returns the smallest value from a list of any number of arguments.

If the arguments consist of strings and numeric values, LEAST() returns 0.

If any argument in the list has the value NULL, LEAST() returns NULL.

The opposite function is GREATEST().

SQL Examples for the LEAST function

 1
 2
 3
 4
 5
 6
 7
 8
 9
10
11

select least(5, 1, 3, 6, 77);
select least(1.01, 1.04, 1.001, 1.0001);
select least('Be''ac''ab''aa''Ab');

select least(5, 1, 3, 6, 77, 'A');
select least('Be''ac''ab''aa''Ab', 65);

select least(5, 1, 3, 6, 77, null);
select least('Be''ac''ab''aa''Ab'null);

least(5, 1, 3, 6, 77)
int(2)
1
least(1.01, 1.04, 1.001, 1.0001)
decimal(7)
1.0001
least('Be', 'ac', 'ab', 'aa', 'Ab')
varchar(2) BINARY
Ab
least(5, 1, 3, 6, 77, 'A')
double(23)
0
least('Be', 'ac', 'ab', 'aa', 'Ab', 65)
double(23)
0
least(5, 1, 3, 6, 77, null)
double(17)
NULL
least('Be', 'ac', 'ab', 'aa', 'Ab', null)
varchar(2) BINARY
NULL
The examples were created with the MyWAY SQL manager: Download

How to use the LEAST() function in MySQL and MariaDB databases

MySQL and MariaDB provide the LEAST() function, used to determine the minimum value among multiple expressions or values by returning the smallest value from the provided list of expressions. Table column names or other expressions can also be used as parameters to obtain the minimum value of, for example, in calculations, comparisons, or when retrieving the minimum value from groups of table columns. The function provides flexibility for multi-value operations. The function returns NULL if any of the provided expressions or values ​​are NULL.
LAST_VALUELASTVALLCASELEASTLEFTLENGTHLENGTHB

Further MySQL und MariaDB SQL Comparison functions

COALESCECOALESCE(%, %)
More about COALESCE Function

DECODE_ORACLEDECODE_ORACLE()
More about DECODE_ORACLE Function

GREATESTGREATEST(%, %)
More about GREATEST Function

INTERVALINTERVAL(%, %)
More about INTERVAL Function

IFIF(Expression, Value1, Value2)
More about IF Function

STRCMPSTRCMP(String 1, String 2)
More about STRCMP Function

Numeric functionsString functionsRegular ExpressionsDate and Time functions
Comparison functionsEncryption & CompressionConversion functionsNULL functions
Aggregate functionsWindow functionsJSON functionsGeometric functions
Sequence functionsInformation functionsDynamic ColumnsMiscellaneous functions
More information about the LEAST SQL function: mysql.com and mariadb.com and w3schools.com
Updated: 2023-09-24ImprintContactTerms & conditionsPrivacy & CookiesUpdatesSitemapFacebookLinkedinTwitterStatistics©2020-2024 Heino Cunze-Fischer