SIGN関数は、Expressionの符号を戻します。
SIGN (Expression)
SIGNには、次のパラメータがあります。
様々ばデータ型を使用してSIGN関数の使用方法を具体的に示します。作成済の表SignExに、異なるデータ型の列が定義されています。まず、表SignExに対してDESCRIBEを実行し、各列のデータ型を確認します。次に、各列を選択してそれぞれの列の値を取得します。SIGN関数を使用して列の符号を戻します。
Command> DESCRIBE SignEx;
Table SAMPLEUSER.SIGNEX:
Columns:
COL1 TT_INTEGER
COL2 TT_BIGINT
COL3 BINARY_FLOAT
COL4 NUMBER (3,2)
1 table found.
(primary key columns are indicated with *)
Command> SELECT Col1 FROM SignEx;
< 10 >
< -10 >
< 0 >
3 rows found.
Command> SELECT SIGN (Col1) FROM SignEx;
< 1 >
< -1 >
< 0 >
3 rows found.
Command> SELECT Col2 FROM SignEx;
< 0 >
< -3 >
< 0 >
3 rows found.
Command> SELECT SIGN (Col2) from SignEx;
< 0 >
< -1 >
< 0 >
3 rows found.
Command> SELECT Col3 FROM SignEx;
< 3.500000 >
< -3.560000 >
< NAN >
3 rows found.
Command> SELECT SIGN (Col3) from SignEx;
< 1 >
< -1 >
< 1 >
3 rows found.
Command> SELECT Col4 FROM SignEx;
< 2.2 >
< -2.2 >
< 0 >
3 rows found.
Command> SELECT SIGN (Col4) from SignEx;
< 1 >
< -1 >
< 0 >
3 rows found.