Skip to main content
All Questions

Overstretched Employees

Hard
Unlock detailed company stats for this questionUpgrade

Given the schema shown below, write a solution to identify if there are any employees that are on multiple projects happening at the same time.

employees projects +---------------+---------+ +---------------+---------+ | id | int |<----+ +->| id | int | | first_name | varchar | | | | title | varchar | | last_name | varchar | | | | start_date | date | | salary | int | | | | end_date | date | | department_id | int |--+ | | | budget | int | +---------------+---------+ | | | +---------------+---------+ | | | departments | | | employees_projects +---------------+---------+ | | | +---------------+---------+ | id | int |<-+ | +--| project_id | int | | name | varchar | +-----| employee_id | int | +---------------+---------+ +---------------+---------+

Your function should return a result in the following format:

department_name | employee_id | first_name | last_name | project_at_risk ----------------+-------------+------------+-----------+---------------- varchar | int | varchar | varchar | varchar (title)

The project at risk is the project that starts later among the two (or more projects) that an employee is working on at that time.

Related courses

Course

Data Analyst Interview Prep

Ace your data analyst interviews—whether you're targeting product, marketing, or business analyst roles. Tackle real take-home case studies, sharpen your technical and dashboarding skills, and get strategies from interviewers at top tech companies and startups.

Course

SQL Interviews

Prepare for SQL interviews by practicing syntax basics, aggregations, and window functions. Learn how to manipulate data, write complex queries, and analyze information from diverse data sets.