Ravindra BagaleCourses & study guides Track your progress

4. WHERE: Keep Only the Rows You Need

4.6 Practice: Filter Coffee Orders by City and Amount

Why. A short filter drill prepares you for interview WHERE questions.

What. Combine comparisons, IN and LIKE on raja_coffee.

How. Write the business question, then the WHERE clause, then SELECT.

Steps

  1. Nashik orders over 300 INR.
  2. Customers in Pune or Kolhapur.
  3. Orders with note text present — next chapter for NULL.

Examples

Example 1 · dataset: raja_coffee

SELECT order_id, city, amount_inr
FROM orders
WHERE city = 'Nashik' AND amount_inr > 300;

Output

order_idcityamount_inr
1007Nashik1080.0
1014Nashik350.0
1022Nashik890.0

Meaning. Nashik filter drill.

Ravindra Bagale's Tip

Read the result aloud: “These rows are ___ because ___.”