Ravindra BagaleCourses & study guides Track your progress

4. WHERE: Keep Only the Rows You Need

4.3 How to Filter Text and Numbers (Quotes vs No Quotes)

Why. Forgetting quotes on text is the #1 beginner syntax error.

What. Text values need single quotes: 'Pune'. Numbers do not: 1000.

How. WHERE city = 'Mumbai' AND amount_inr > 700

Steps

  1. Filter city Goa with quotes.
  2. Filter amount without quotes.
  3. Combine both with AND.

Examples

Example 1 · dataset: raja_coffee

SELECT order_id, city, amount_inr
FROM orders
WHERE city = 'Mumbai' AND amount_inr > 700;

Output

order_idcityamount_inr
1002Mumbai720.0
1010Mumbai930.0
1018Mumbai840.0

Meaning. Mumbai orders over 700 INR.

Ravindra Bagale's Tip

If SQLite says no such column Pune, you forgot quotes around the text.