MIN |
Minimum |
---|---|
SQL Server | Microsoft SQL Server |
Syntaxe
MIN([ALL | DISTINCT] argument) |
Paramètres
Nom | Description |
---|---|
argument | Ce paramètre permet d'indiquer que le champ devant être comparer. |
Description
Cette fonction retourne la plus basse valeur d'une liste d'argument.
Exemple
Voici un exemple permettant d'afficher les plus petites valeurs en contournant le problème qu'il n'accepte pas une liste de valeurs directement comme paramètre dans la fonction :
- SELECT 'MIN(5,-18)=' AS Text, MIN(X) AS Result
- FROM (SELECT 5 AS X
- UNION
- SELECT - 18 AS X) AS TableData
- UNION
- SELECT 'MIN(0.25,0.115)=' AS Text, MIN(X) AS Result
- FROM (SELECT 0.25 AS X
- UNION
- SELECT 0.115 AS X) AS TableData_4
- UNION
- SELECT 'MIN(1,2,3,4,5)=' AS Text, MIN(X) AS Result
- FROM (SELECT 1 AS X
- UNION
- SELECT 2 AS X
- UNION
- SELECT 3 AS X
- UNION
- SELECT 4 AS X
- UNION
- SELECT 5 AS X) AS TableData_3
- UNION
- SELECT 'MIN(5,4,3,2,1)=' AS Text, MIN(X) AS Result
- FROM (SELECT 5 AS X
- UNION
- SELECT 4 AS X
- UNION
- SELECT 3 AS X
- UNION
- SELECT 2 AS X
- UNION
- SELECT 1 AS X) AS TableData_2
- UNION
- SELECT 'MIN(24,34,13,72,100,1,34)=' AS Text, MIN(X) AS Result
- FROM (SELECT 24 AS X
- UNION
- SELECT 34 AS X
- UNION
- SELECT 13 AS X
- UNION
- SELECT 72 AS X
- UNION
- SELECT 100 AS X
- UNION
- SELECT 1 AS X
- UNION
- SELECT 34 AS X) AS TableData_1
on obtiendra le résultat suivant :
Text | Result |
MIN(5,-18)= | -18.000 |
MIN(0.25,0.115)= | 0.115 |
MIN(1,2,3,4,5)= | 1.000 |
MIN(5,4,3,2,1)= | 1.000 |
MIN(24,34,13,72,100,1,34)= | 1.000 |
Voir également
Langage de programmation - Sybase - Référence de fonctions - AVG
Langage de programmation - Sybase - Référence de fonctions - MAX
Articles - Les géants de l'informatique - Microsoft
Dernière mise à jour : Dimanche, le 7 juin 2015