Apache Presto - 範圍運算子



Between 運算子用於測試指定值,該值存在於最小值和最大值範圍內。

查詢 1

presto:default> select 30.5 between 10 and 40 as range; 

結果

 range 
------- 
 true 
(1 row) 

查詢 2

presto:default> select 4.5 is null; 

結果

 _col0 
------- 
 false 
(1 row) 

此處,4.5 是值且不為 null,因為它已用 null 檢查過了,所以結果為 false。

查詢 3

presto:default> select 3 is not null;

結果

 _col0 
------- 
 true 
(1 row) 

Greatest(x,y)

如果 **x** 的值大於 **y**,則它返回 **x**,否則返回 **y**。

查詢

presto:default> select greatest(200,300) as greatest; 

結果

 greatest 
---------- 
  300 
(1 row) 

輸出作為兩個值中的較大值返回。

Least(x,y)

從給定的兩個值中返回較小值。

查詢

presto:default> select least('a','b') as result; 

結果

 result 
-------- 
   a

此處,最小的字元值為“a”,因此它在結果中返回。

apache_presto_basic_sql_operations.htm
廣告
© . All rights reserved.