postgresql 函数获取多个字段的数字大小值

1、GREATEST(n1,n2,n3,……….) 获取最大值

testdb=#SELECT GREATEST(3,5,1,8,33,99,34,55,67,43); 
+---------------------------------------------------------+ 
| GREATEST(3,5,1,8,33,99,34,55,67,43)                     | 
+---------------------------------------------------------+ 
| 99                                                      | 
+---------------------------------------------------------+ 
1 row in set (0.00 sec) 

2、LEAST(N1,N2,N3,N4,……) 获取最小值

testdb=#SELECT LEAST(3,5,1,8,33,99,34,55,67,43); 
+---------------------------------------------------------+ 
| LEAST(3,5,1,8,33,99,34,55,67,43)                        | 
+---------------------------------------------------------+ 
| 1                                                       | 
+---------------------------------------------------------+ 
1 row in set (0.00 sec) 

其他更多函数参考:http://developer.51cto.com/art/201401/426252_all.htm

 

    原文作者:PostgreSQL
    原文地址: https://www.cnblogs.com/liqiu/p/4484071.html
    本文转自网络文章,转载此文章仅为分享知识,如有侵权,请联系博主进行删除。
点赞