Sap-hana-sql-operators
提供:Dev Guides
SAP HANA-SQLオペレーター
演算子は、比較や算術演算などの操作を実行するために、主にSQL文でWHERE句とともに使用される特殊文字です。 SQLクエリで条件を渡すために使用されます。
以下に示す演算子タイプは、HANAのSQLステートメントで使用できます-
- 算術演算子
- 比較/関係演算子
- 論理演算子
- 集合演算子
算術演算子
算術演算子は、加算、減算、乗算、除算、パーセントなどの単純な計算機能を実行するために使用されます。
Operator | Description |
---|---|
+ | Addition − Adds values on either side of the operator |
- | Subtraction − Subtracts right hand operand from left hand operand |
* | Multiplication − Multiplies values on either side of the operator |
/ | Division − Divides left hand operand by right hand operand |
% | Modulus − Divides left hand operand by right hand operand and returns remainder |
比較演算子
比較演算子は、SQLステートメントの値を比較するために使用されます。
Operator | Description |
---|---|
= | Checks if the values of two operands are equal or not, if yes then condition becomes true. |
!= | Checks if the values of two operands are equal or not, if values are not equal then condition becomes true. |
<> | Checks if the values of two operands are equal or not, if values are not equal then condition becomes true. |
> | Checks if the value of left operand is greater than the value of right operand, if yes then condition becomes true. |
< | Checks if the value of left operand is less than the value of right operand, if yes then condition becomes true. |
>= | Checks if the value of left operand is greater than or equal to the value of right operand, if yes then condition becomes true. |
⇐ | Checks if the value of left operand is less than or equal to the value of right operand, if yes then condition becomes true. |
!< | Checks if the value of left operand is not less than the value of right operand, if yes then condition becomes true. |
!> | Checks if the value of left operand is not greater than the value of right operand, if yes then condition becomes true. |
論理演算子
論理演算子は、SQLステートメントで複数の条件を渡すために使用されるか、条件の結果を操作するために使用されます。
Operator | Description |
---|---|
ALL | The ALL Operator is used to compare a value to all values in another value set. |
AND | The AND operator allows the existence of multiple conditions in an SQL statement’s WHERE clause. |
ANY | The ANY operator is used to compare a value to any applicable value in the list according to the condition. |
BETWEEN | The BETWEEN operator is used to search for values that are within a set of values, given the minimum value and the maximum value. |
EXISTS | The EXISTS operator is used to search for the presence of a row in a specified table that meets certain criteria. |
IN | The IN operator is used to compare a value to a list of literal values that have been specified. |
LIKE | The LIKE operator is used to compare a value to similar values using wildcard operators. |
NOT | The NOT operator reverses the meaning of the logical operator with which it is used. Eg − NOT EXISTS, NOT BETWEEN, NOT IN, etc.* This is a negate operator*. |
OR | The OR operator is used to compare multiple conditions in an SQL statement’s WHERE clause. |
IS NULL | The NULL operator is used to compare a value with a NULL value. |
UNIQUE | The UNIQUE operator searches every row of a specified table for uniqueness (no duplicates). |
集合演算子
集合演算子は、2つのクエリの結果を1つの結果に結合するために使用されます。 データ型は両方のテーブルで同じである必要があります。
- UNION -2つ以上のSelectステートメントの結果を結合します。 ただし、重複する行は削除されます。
- UNION ALL -この演算子はUnionに似ていますが、重複行も表示します。
- INTERSECT -交差操作は、2つのSELECTステートメントを結合するために使用され、両方のSELECTステートメントに共通するレコードを返します。 Intersectの場合、列とデータ型の数は両方のテーブルで同じでなければなりません。
- MINUS -マイナス演算は、2つのSELECTステートメントの結果を結合し、結果の最初のセットに属し、最初の出力から2番目のステートメントの行を削除する結果のみを返します。