Operators in SAP HANA Cloud

Do you want to know about operators in SAP HANA? This is the right article to check various types of operators in SAP HANA Cloud.

Operators are badges or symbol that tell or gives instructions to the system to perform required functions as per the end users either mathematically or logically.

The calculation compares the values between two numbers or two pieces of data and assigns the values done through this function. Let’s get started to see more about operators in SAP HANA.

Types of Operators in SAP HANA Cloud

There are seven types of operators in SAP HANA to perform their own unique functions. Below are the types.

  • Unary and binary operators
  • Precedence operator
  • Arithmetic operator
  • String operator
  • Logical operators
  • Set operators

Unary and Binary Operators

Operator Performing Functions Illustration
UnaryIt is applicable to only one operand and a single value expression.Plus operator(+)
Minus operator(-)
Negation operator(NOT)
BinaryThis applies to two operands or two value expressions with one operatorAdditive operator(+,-)
Multiplicative operator(*,/)
Logical operator(AND, OR)

Precedence Operators

In this, we can use more than one operator. This means multiple operators can use in this type. If the required operator is more than one, then SAP HANA analyze them based on operator precedence.

The values expressed with parentheses will be taken as a prior consideration. The different types of operators are described below. SAP HANA estimates operators with equal precedence from left to right.

Precedence Operator Operator Functions
Highest ()Parentheses
+,- Unary operator with positive and negative
*,/Multiplication, Division
+,-Addition, subtraction
=,!=,<,>,<=,>=,like, Between ||Comparison and Concatenation
AND
Connection operator or conjunction
ORDisjunction operator
Lowest NOT Logical negation

Arithmetic Operators

Mathematical operations such as adding, subtracting, multiplying, and dividing numeric values can be done by this arithmetic operator in SAP HANA.

Operator Symbol Example
Addition +3+5 = 8
Subtraction6-3 = 3
Multiplication *4*3 = 12
Division /20/2 = 10

String Operator

In the SAP HANA, the string operator concatenates or combines two strings, expressions, or constants into one.

OperatorDescription
First name || Last nameWe can concatenate two strings using ‘||’ but when any one of the strings is NULL, it returns NULL.

Comparison Operators

Compares the number or thing or strings and performs the estimations. The comparison operator does not return the values as the arithmetic operator does in SAP HANA. It returns either 1 which indicates true or 0 for false.

Operator DescriptionExamples
= Equal toSelect * From employee where age =25
> Greater than Select * From employees where age >25
< Less thanSelect * From employees where age <25
>= Greater than or equal toSelect * From employees where age >=25
<= Less than or equal toSelect * From employees where age <=25
!=,<> Not equal toSelect * From employees where age !=25
Select * From employees where age <>25

Logical Operators

In this cloud version of SAP HANA, the logical operator is used to connect two or more values or expressions. We can also nullify them using the NOT operator.

Operator SyntaxDefinition
ANDWHERE condition 1 AND condition 2In this, if both the conditions are true, then the combined conditions are also true and if one condition is false the output will be false.
ORWHERE condition 1 OR condition 2In OR condition, if any one condition is true, then the combined condition is true. If both conditions are false, then they return false and unknown else.
NOTWHERE NOT conditionIf condition A is true then B is false, if A is false then B is true. Also, return UNKNOWN if the condition is UNKNOWN.

SET Operators

The multiple queries are combined to return a single output by set operators. Below are the types of set operators in SAP HANA.

Operator Returned output
UNIONCombines the results of two or more select statements or query expressions.
UNION ALLCombines the results of two or more select statements or query expressions, even duplicate rows.
INTERSECTCombines the results of two or more select statements or query expressions, and returns all common rows.
EXCEPT or MINUSTakes the output from the first query and then removes the rows selected by the second query.

Conclusion

In this tutorial, we have seen all the types of operators in SAP HANA. Also, we have seen descriptions, syntax, and its uses as well.

  • Unary and Binary Operators
  • Precedence Operators
  • Arithmetic Operators
  • String Operators
  • Comparison Operators
  • Logical Operators
  • SET Operators

You may also read: