Skip to main content
SQL • LESSON 163

UNION with Filters

How can we combine only active employees and active contractors?

Advanced3 Minutes1760 XP
🤔 THE QUESTION

How can we combine only active employees and active contractors?

💡 WHAT IS IT?

Applying WHERE clauses in individual SELECT queries filters each branch before the UNION executes.

🎯 WHAT IS IT USED FOR?

Active workforce consolidation, valid transaction merging across multiple systems.

💻 EXAMPLE
SELECT name
FROM employees
WHERE status = 'Active'
UNION
SELECT name
FROM contractors
WHERE status = 'Active';

🎯 Mission Objectives

Practice typing production-grade SQL code for UNION with Filters.

  • UNION with WHERE
  • Filtered set operation
  • Status matching
  • Active workforce merge