Arithmetic and Comparison Operators in SQL
Explore how to apply arithmetic and comparison operators in SQL to manipulate numeric data and write conditional queries. Understand operators such as addition, subtraction, equality checks, pattern matching, and range filtering to retrieve and manage database records efficiently.
Types of operators
Operators are used for specifying conditions in SQL statements. SQL supports various types of operators, which can be classified as follows:
Arithmetic operators
Comparison operators
Logical operators
Arithmetic operators
Arithmetic operators perform arithmetic operations on numeric data. The arithmetic operators supported by SQL are listed in the table below:
List of Arithmetic Operators
Operator | Description |
| Adds two numeric operands |
| Subtracts one numeric operand from another |
| Multiplies two numeric operands |
| Divides one numeric operand by another |
| Calculates the remainder of dividing two numeric operands |
In the SQL query example above, we use various arithmetic operators to perform arithmetic operations on numeric data. The value of the first column returned is 3 + 4 = 7, the value of the second column returned is 5 - 2 = 3, the value of the third column returned is 6 * 8 = 48, the value of the fourth column returned is ...