Beginner

16. Comparison Operators

Learn how SQL comparison operators compare values and help filter database records.

📘 Lesson 16 of 728 ⏱ 8 min 🎯 Beginner

Comparison operators are symbols used to compare two values in SQL. Common operators include equal to (=), greater than (>), less than (<), greater than or equal to (>=), less than or equal to (<=), and not equal to (<>). These operators are frequently used inside WHERE conditions.

Comparison operators are essential when answering business questions such as which employees earn more than a specific amount, which transactions exceed a particular value, or which products have prices below a certain threshold.

A financial analyst wants to identify transactions greater than ₹1,00,000. A comparison operator can be used to filter the TransactionAmount column.

SQL
SELECT
    TransactionID,
    TransactionAmount
FROM Transactions
WHERE TransactionAmount > 100000;

Comparison operators are used in financial analysis, employee analysis, sales analysis, transaction monitoring, compliance checks, and customer analysis.

  • = means equal to.
  • > means greater than.
  • < means less than.
  • >= means greater than or equal to.
  • <= means less than or equal to.
  • <> generally means not equal to.
Which operator means greater than?

The greater-than operator is >.

Which operator is commonly used for not equal?

The <> operator is commonly used for not equal. Some database systems also support !=.

Have you finished this lesson?

Introduction to SQL – All Lessons