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

 

posted @ 2015-05-07 10:18  李秋  阅读(6538)  评论(0编辑  收藏  举报