mysql 数学函数

greatest()是MySQL的一个Math函数。此函数用于从列表中获取最大数。

语法

select greatest(exp1, exp2, exp3....); 

参数:

Exp1, exp2, exp3.... expn:求最大数的表达式。

返回

此函数返回列表中的最大数字。

示例 1

Select greatest(4,5,3,9,0); 

输出:

mysql> Select greatest(4,5,3,9,0);
+---------------------+
| greatest(4,5,3,9,0) |
+---------------------+
|                   9 |
+---------------------+
1 row in set (0.01 sec)

示例 2

Select greatest('j','a','v','a'); 

输出:

mysql> Select greatest('j','a','v','a');
+---------------------------+
| greatest('j','a','v','a') |
+---------------------------+
| v                         |
+---------------------------+
1 row in set (0.00 sec)

示例 3

Select greatest('yxjc123','string_finction','math_function','date_function',""); 

输出:

mysql> Select greatest('yxjc123','string_finction','math_function','date_function',"");
+--------------------------------------------------------------------------+
| greatest('yxjc123','string_finction','math_function','date_function',"") |
+--------------------------------------------------------------------------+
| yxjc123                                                                  |
+--------------------------------------------------------------------------+
1 row in set (0.00 sec)