MAX |
Maximum |
---|---|
Oracle Database SQL |
Syntaxe
Max(argument) |
Paramètres
Nom | Description |
---|---|
argument | Ce paramètre permet d'indiquer que le champ devant être comparer. |
Description
Cette fonction retourne la plus haute valeur d'une liste d'argument.
Exemple
Voici un exemple permettant d'afficher les plus grandes valeurs en contournant le problème qu'il n'accepte pas une liste de valeurs directement comme paramètre dans la fonction :
- SELECT 'MAX(5,-18)=' AS Text,max(X) AS Result FROM (SELECT 5 AS X FROM DUAL UNION SELECT -18 AS X FROM DUAL) UNION
- SELECT 'MAX(0.25,0.115)=' AS Text, max(X) AS Result FROM (SELECT 0.25 AS X FROM DUAL UNION SELECT 0.115 AS X FROM DUAL) UNION
- SELECT 'MAX(1,2,3,4,5)=' AS Text,max(X) AS Result FROM (SELECT 1 AS X FROM DUAL UNION SELECT 2 AS X FROM DUAL UNION SELECT 3 AS X FROM DUAL UNION SELECT 4 AS X FROM DUAL UNION SELECT 5 AS X FROM DUAL) UNION
- SELECT 'MAX(5,4,3,2,1)=' AS Text, max(X) AS Result FROM (SELECT 5 AS X FROM DUAL UNION SELECT 4 AS X FROM DUAL UNION SELECT 3 AS X FROM DUAL UNION SELECT 2 AS X FROM DUAL UNION SELECT 1 AS X FROM DUAL) UNION
- SELECT 'MAX(24,34,13,72,100,1,34)=' AS Text, max(X) AS Result FROM (SELECT 24 AS X FROM DUAL UNION SELECT 34 AS X FROM DUAL UNION SELECT 13 AS X FROM DUAL UNION SELECT 72 AS X FROM DUAL UNION SELECT 100 AS X FROM DUAL UNION SELECT 1 AS X FROM DUAL UNION SELECT 34 AS X FROM DUAL);
on obtiendra le résultat suivant :
Text | Result |
MAX(5,-18)= | 5.000 |
MAX(0.25,0.115)= | 0.250 |
MAX(1,2,3,4,5)= | 5.000 |
MAX(5,4,3,2,1)= | 5.000 |
MAX(24,34,13,72,100,1,34)= | 100.000 |
Voir également
Article - Les géants de l'informatique - Oracle
Dernière mise à jour : Lundi, le 11 mai 2015