函数说明
有两个或者更多的参数,返回最小的参数值。假如任意一个变量为 NULL,则LEAST()的返回值为 NULL。LEAST()对参数进行比较所依据的规则同 GREATEST()相同。
示例
- 示例 1:参数值为整型数字,返回最小的参数值。
gbase> SELECT LEAST(2,0) FROM t;
+------------+
| LEAST(2,0) |
+------------+
| 0 |
+------------+
1 row in set
- 示例 2:参数值为浮点型数字,返回最小的参数值。
gbase> SELECT LEAST(34.0,3.0,5.0,767.0) FROM t;
+---------------------------+
| LEAST(34.0,3.0,5.0,767.0) |
+---------------------------+
| 3.0 |
+---------------------------+
1 row in set
- 示例 3:参数值为字符串,不区分大小写。
gbase> SELECT LEAST('B','A','C') FROM t;
+--------------------+
| LEAST('B','A','C') |
+--------------------+
| A |
+--------------------+
1 row in set
gbase> SELECT LEAST('B','a', 'C') FROM t;
+---------------------+
| LEAST('B','a', 'C') |
+---------------------+
| a |
+---------------------+
1 row in set
- 示例 4:参数值为字符串,字符串参数前加上 BINARY,区分大小写。
gbase> SELECT LEAST(BINARY 'B',BINARY 'a', 'C') FROM t;
+-----------------------------------+
| LEAST(BINARY 'B',BINARY 'a', 'C') |
+-----------------------------------+
| B |
+-----------------------------------+
1 row in set
- 示例 5:参数值中包含 NULL,则执行结果为 NULL。
gbase> SELECT LEAST('C',NULL,'B') FROM t;
+---------------------+
| LEAST('C',NULL,'B') |
+---------------------+
| NULL |
+---------------------+
1 row in set