Open In App

SQL | Arithmetic Operators

Last Updated : 12 Aug, 2025
Comments
Improve
Suggest changes
39 Likes
Like
Report

Arithmetic operators in SQL are used to perform mathematical operations on table data. These operators help in calculating totals, differences, percentages, and other numeric transformations directly in queries.

These operations can be applied to:

  • A single column
  • Two or more columns
  • Constant values with column data

List of Arithmetic Operators in SQL

OperatorDescription
+Addition
-Subtraction
/Division
*Multiplication
%Modulus (Remainder)

1. Addition (+)

The addition operator is used to sum values. Performs addition between:

  • Column and constant
  • Two columns

Example 1: Addition with constant

SELECT employee_id, employee_name, salary, 
salary + 100 AS "salary + 100"
FROM addition;

Output:

employee_idemployee_namesalarysalary+100
1Alex2500025100
2RR5500055100
3JPM5200052100
4GGSHMR1231212412

Example 2: Addition of two columns

SELECT employee_id, employee_name, salary, 
salary + employee_id AS "salary + employee_id"
FROM addition;

Output:

employee_idemployee_namesalarysalary+employee_id
1Alex2500025001
2RR5500055002
3JPM5200052003
4GGSHMR1231212316

2. Subtraction (-)

The subtraction operator deducts one value from another. Performs subtraction between:

  • Column and constant
  • Two columns

Example 1: Subtracting a constant

SELECT employee_id, employee_name, salary, 
salary - 100 AS "salary - 100"
FROM subtraction;

Output:

employee_idemployee_namesalarysalary-100
12Finch1500014900
22Peter2500024900
32Warner56005500
42Watson9000089900

Example 2: Subtracting one column from another

SELECT employee_id, employee_name, salary, 
salary - employee_id AS "salary - employee_id"
FROM subtraction;

Output:

employee_idemployee_namesalarysalary-employee_id
12Finch1500014988
22Peter2500024978
32Warner56005568
42Watson9000089958

3. Multiplication (*)

The multiplication operator multiplies values by constants or other column values. It multiplies:

  • Column and constant
  • Two columns

Example 1: Multiplying with a constant

SELECT employee_id, employee_name, salary, 
salary * 100 AS "salary * 100"
FROM addition;

Output:

employee_idemployee_namesalarysalary*100
1Finch250002500000
2Peter550005500000
3Warner520005200000
4Watson123121231200

Example 2: Multiplying two columns

SELECT employee_id, employee_name, salary, 
salary * employee_id AS "salary * employee_id"
FROM addition;

Output:

employee_idemployee_namesalarysalary*employee_id
1Finch2500025000
2Peter55000110000
3Warner52000156000
4Watson1231249248

5. Division (/)

The division operator divides one value by another. Example for division is similar to multiplication but returns quotient instead of product.

Example:

SELECT employee_id, employee_name, salary, 
salary / 100 AS "salary / 100"
FROM addition;

Output:

employee_idemployee_namesalarysalary/100
1Finch25000250
2Peter55000550
3Warner52000520
4Watson12312123.12

6. Modulus (%)

The modulus operator returns the remainder of a division.

Useful for:

  • Even/Odd check
  • Pattern-based calculations

Example 1: Modulus with constant

SELECT employee_id, employee_name, salary, 
salary % 25000 AS "salary % 25000"
FROM addition;

Output:

employee_idemployee_namesalarysalary%25000
1Finch250000
2Peter550005000
3Warner520002000
4Watson1231212312

Example 2: Modulus between columns

SELECT employee_id, employee_name, salary, 
salary % employee_id AS "salary % employee_id"
FROM addition;

Output:

employee_idemployee_namesalarysalary%employee_id
1Finch250000
2Peter550000
3Warner520001
4Watson123120

7. Arithmetic Operations with NULL

When any arithmetic operation is performed on a NULL value, the result is always NULL.

Example:

SELECT employee_id, employee_name, salary, type, 
type + 100 AS "type + 100"
FROM addition;

Output:

employee_idemployee_namesalarytypetype+100
1Finch25000NULLNULL
2Peter55000NULLNULL
3Warner52000NULLNULL
4Watson12312NULLNULL

Key Notes on NULL:

  • NULL means unknown/unavailable
  • It is not the same as 0 or empty string
  • Any operation with NULL results in NULL
Suggested Quiz
6 Questions

Which of the following is NOT a SQL arithmetic operator?

  • A

     Ternary

  • B

    Modulus

  • C

    Addition

  • D

     Subtraction

Explanation:

Addition, Subtraction, and Modulus are all SQL Arithmetic Operators.

The number of operands used by a Unary Operator is

  • A

    1

  • B

    2

  • C

    3

  • D

    4

Explanation:

The number of operands used by Unary Operator is 1.

What is the result of any arithmetic operation involving NULL?

  • A

    0

  • B

    Error

  • C

    Empty string

  • D

    NULL

Explanation:

Any arithmetic with NULL returns NULL because NULL represents an unknown value.

Which operator is used to calculate the remainder of a division in SQL?

  • A

    /

  • B

    %

  • C

    *

  • D

    -

Explanation:

The modulus operator (%) returns the remainder, as shown in the salary % 25000 example.

What does the following query compute?
SELECT salary + 100 FROM addition;

  • A

    Subtracts 100 from salary

  • B

    Multiplies salary by 100

  • C

    Adds 100 to each salary value

  • D

    Divides salary by 100

Explanation:

The article’s Addition section shows salary + constant increases the salary value by that constant.

Which arithmetic operator would you use to check whether a salary is even or odd?

  • A

    %

  • B

    *

  • C

    +

  • D

    /

Explanation:

The modulus operator helps identify even/odd by checking salary % 2.

Quiz Completed Successfully
Your Score :   2/6
Accuracy :  0%
Login to View Explanation
1/6 1/6 < Previous Next >

Article Tags :

Explore