SQL Subtraction Operator

The SQL Subtraction operator is used to subtract one numeric value from another. It is commonly used in SQL queries to compute differences between two columns, perform calculations, and analyze data effectively.

In this tutorial, we will explore how the subtraction operator works in SQL, its syntax, and detailed examples demonstrating its usage.


Syntax of SQL Subtraction Operator

The SQL subtraction operator can be used in two ways:

  • Subtracting two numbers directly: SELECT 50 - 20 AS result;
  • Subtracting values from table columns:
</>
Copy
SELECT column1 - column2 AS result
FROM table_name;

Examples of SQL Subtraction Operator

1 Simple Subtraction Example

We can perform subtraction directly in a SQL query:

</>
Copy
SELECT 100 - 45 AS difference;

Output: