Apache Presto - Logical Operator


Logical operators work on Boolean operands and produce Boolean results. Let’s take a few examples to see how logical operators work in Presto −

Query 1

select 3 < 2 and 4 > 1 as logical; 

Result

logical 
--------- 
 false 

Here, 4 > 1 is false so “AND” operator returns the result as false.

Query 2

presto:default> select 3 < 2 or 4 > 1 as logical;

Result

logical 
--------- 
 true 
(1 row) 

Both conditions are true, hence the result is true.

Query 3

presto:default> select 3 not in (1,2) as not_operator; 

Result

 not_operator 
-------------- 
 true 
(1 row)

Here, 3 value is not in the given set (1,2) hence it produces true result.

apache_presto_basic_sql_operations.htm
Advertisements