Skip to main content
SQL โ€ข LESSON 163

UNION with Filters

How can we combine only active employees and active contractors?

Advancedโฑ 3 Minutesโญ 1760 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