Multiply

The multiply operator (*) multiplies two operands and returns the product.

Note: A configuration parameter is available to control whether this operator allows precision/scale to exceed 38. See Decimal Digit Limitation on Functions, for details.

DECIMAL and NUMERIC Data Types

When the multiply operator is applied to operands that include DECIMAL or NUMERIC data types, the output data type, precision and scale might depend on the data type, precision and scale of the operands, as shown below.

Syntax

operand1 * operand2

Remarks

The order of the inputs (operands) has no effect on the output data type.
The outputs for multiplying DECIMAL and NUMERIC data types with each other and with other data types are shown in the table.

Inputs

Output

DECIMAL(p1,s1) * DECIMAL(p2,s2)

DECIMAL(p1+p2,s1+s2)

DECIMAL(p1,s1) * NUMERIC(p2,s2)

NUMERIC(p1,s1) * NUMERIC(p2,s2)

NUMERIC(p1+p2,s1+s2)

DECIMAL(p1,s1) * TINYINT

DECIMAL(p+3,s)

DECIMAL(p1,s1) * SMALLINT

DECIMAL(p+5,s)

DECIMAL(p1,s1) * INTEGER

DECIMAL(p+10,s)

DECIMAL(p1,s1) * BIGINT

DECIMAL(p+19,s)

DECIMAL(p,s) * not-DECIMAL-or-NUMERIC

DECIMAL(p,s)

NUMERIC(p,s) * not-DECIMAL-or-NUMERIC

NUMERIC(p,s)

Examples

DECIMAL(6,2) * TINYINT -> DECIMAL(9,2)
DECIMAL(6,2) * SMALLINT -> DECIMAL(11,2)

INTERVAL Type

INTERVAL can be multiplied by numbers. The output data type is INTERVAL.

Syntax

INTERVAL * NUMERIC

Examples

INTERVAL '1' DAY * 10 = INTERVAL '10 00:00:00' DAY TO SECOND
INTERVAL '10' DAY * .1 = INTERVAL '1 00:00:00' DAY TO SECOND

Mixed Data Types

The multiply operator can be applied to operands that have a wide variety of data types, including operands comparable or castable to data types that can accept arithmetic operators.

Syntax

operand1 * operand2

Remarks

The operand data types and resulting output data types are shown in the table.

Operand1

Operand2

Output

TINYINT
SMALLINT
INTEGER
BIGINT

TINYINT
SMALLINT
INTEGER
BIGINT
STRING

INTEGER

TINYINT
SMALLINT
INTEGER
BIGINT

FLOAT
REAL

FLOAT

TINYINT
SMALLINT
INTEGER
BIGINT

DECIMAL
NUMERIC

DECIMAL

FLOAT
REAL

TINYINT
SMALLINT
INTEGER
BIGINT
DECIMAL

FLOAT

FLOAT
REAL

FLOAT
REAL

FLOAT
REAL

DECIMAL
NUMERIC

DECIMAL

DECIMAL
NUMERIC

TINYINT
SMALLINT
INTEGER
BIGINT
STRING

DECIMAL
NUMERIC

FLOAT
REAL

DECIMAL
NUMERIC

DECIMAL
NUMERIC

FLOAT

STRING

STRING
TINYINT
SMALLINT
INTEGER
BIGINT
NUMERIC
FLOAT
REAL
DECIMAL

DECIMAL
INTEGER
INTEGER
INTEGER
INTEGER
DECIMAL
FLOAT
FLOAT
DECIMAL

NULL

TINYINT
SMALLINT
INTEGER
BIGINT
NUMERIC
FLOAT
REAL
DECIMAL
STRING
NULL

NULL

TINYINT
SMALLINT
INTEGER
BIGINT
NUMERIC
FLOAT
REAL
DECIMAL
STRING

NULL

INTERVAL

NUMERIC

INTERVAL