Altimetrik's Workforce Directory team needs a validation query for employee extracts. Using the tables below, write PostgreSQL SQL that produces both a deliberately duplicated employee row and the first 50% of eligible workforce records.
Requirements
- Join
employees to departments and retain only active employees with a matching department.
- Return the row for
employee_id = 104 exactly twice using UNION ALL.
- Return the first half of eligible employees, ordered by ascending
employee_id. Use NTILE(2) so the query remains data-driven.
- Add an
operation column with duplicated or first_half, and sort the final result by operation and employee ID.