Skip to main content
SQL • LESSON 52

AND with OR

How can we combine AND and OR conditions to build more precise filters?

Intermediate3 Minutes650 XP
🤔 THE QUESTION

How can we combine AND and OR conditions to build more precise filters?

💡 WHAT IS IT?

Parentheses group logical expressions to enforce correct operator precedence when combining AND and OR logic.

🎯 WHAT IS IT USED FOR?

Multi-department threshold queries, composite eligibility rules, complex audit criteria.

💻 EXAMPLE
SELECT name, department, salary
FROM employees
WHERE (department = 'Engineering' AND salary > 90000)
OR (department = 'Analytics' AND salary > 85000);

🎯 Mission Objectives

Practice typing production-grade SQL code for AND with OR.

  • Precedence parentheses
  • AND/OR combination
  • Complex logic
  • Grouping conditions