PostgreSQL

Arithmetic Operators

Basic arithmetic operations can be done using SQL command line interface.

Syntax

SELECT <expression>;
Operator Name Operator Description
Addition + Adds values together.
Subtraction - Subtracts values.
Multiplication * Performs multiplication operation.
Divison / Adds values together.
Modulus % Returns the remainder of statement.
Exponent ^ Returns the remainder of statement.
Factorial ! Returns the remainder of statement.

Example #1

SELECT 10 * 2;
Returns the value of 10 * 2
?column?
20

Example #2

SELECT 5!;
Returns the value of 5 factorial
?column?
120