Ravindra BagaleCourses & study guides Track your progress

4. WHERE: Keep Only the Rows You Need

4.2 Comparison Operators (=, !=, <, >, <=, >=) with Money Examples

Why. Money questions use comparisons every day.

What. Operators: = != <> < > <= >= compare numbers or text.

How. WHERE amount_inr >= 1000 keeps large orders.

Steps

  1. Find orders of at least 1000 INR.
  2. Find orders under 500 INR.
  3. Try != for “not equal”.

Examples

Example 1 · dataset: raja_coffee

SELECT order_id, amount_inr
FROM orders
WHERE amount_inr >= 1000
ORDER BY amount_inr DESC;

Output

order_idamount_inr
10161780.0
10131680.0
10071080.0
10041050.0

Meaning. Large coffee orders in INR.

Ravindra Bagale's Tip

For money, decide currency first (INR vs USD) — never mix blindly.