Apache Presto - Arithmetic Operator


Following sample queries are an example of arithmetic operators.

Query 1

presto:default> select 4 + 5 as addition;

Result

 addition 
---------- 
   9  
(1 row)

From the above result “as” is used for alias for the query.

Query 2

presto:default> select 4.5-3.5 as sub; 

Result

 sub 
----- 
 1.0 
(1 row) 

The output is subtraction between two values.

Query 3

presto:default> select 4 % 2 as modulus;

Result

 modulus 
--------- 
   0 
(1 row) 

The output is returned as the modulus for given values.

apache_presto_basic_sql_operations.htm
Advertisements