Find Employees With Over a Year of Tenure and No Review in the Last Six Months

Quick Overview

Write a SQL query that finds employees with more than one year of tenure who have had no performance review in the last six months, measured from a fixed date. It tests date interval arithmetic, inclusive and exclusive boundaries, and filtering on the absence of related rows.

Find Employees With Over a Year of Tenure and No Review in the Last Six Months

Company: Lattice

Role: Data Scientist

Category: Data Manipulation (SQL/Python)

Difficulty: medium

Interview Round: Other

Using 2024-06-01 as today's date, return the `employee_id` and `name` of every employee who has been at the company for more than one year and has had no performance review within the last 6 months. ### Input Table(s) `employees` | Column | Type | Meaning | | --- | --- | --- | | employee_id | INT | Employee id. Primary key. | | name | VARCHAR(100) | Employee name. NOT NULL. | | hire_date | DATE | Date the employee joined. NOT NULL. | `performance_reviews` | Column | Type | Meaning | | --- | --- | --- | | review_id | INT | Review id. Primary key. | | employee_id | INT | Employee who was reviewed. Foreign key to `employees(employee_id)`. | | review_date | DATE | Date of the review. NOT NULL. | ### Output Contract - Columns, in this order: `employee_id`, `name`. - One row per qualifying employee, with no duplicates. - Sort by `employee_id` ascending. ### Example `employees` | employee_id | name | hire_date | | --- | --- | --- | | 1 | Ana | 2020-03-15 | | 2 | Ben | 2023-06-01 | | 3 | Chen | 2022-01-10 | | 4 | Dara | 2021-09-30 | | 5 | Eli | 2024-02-01 | | 6 | Fay | 2019-07-07 | `performance_reviews` | review_id | employee_id | review_date | | --- | --- | --- | | 101 | 3 | 2023-12-01 | | 102 | 4 | 2023-11-30 | | 103 | 4 | 2022-11-15 | | 104 | 6 | 2023-05-05 | | 105 | 6 | 2024-05-20 | Expected result: | employee_id | name | | --- | --- | | 1 | Ana | | 4 | Dara | Ana has more than a year of tenure and no reviews at all. Dara's latest review (2023-11-30) is one day before the 6-month window opens. Ben has exactly one year of tenure, which is not more than one year. Chen's review on 2023-12-01 falls inside the window, Eli was hired too recently, and Fay was reviewed on 2024-05-20. ### Constraints and Clarifications - More than one year of tenure means `hire_date` is strictly before 2023-06-01. An employee hired on 2023-06-01 does not qualify. - A review is within the last 6 months when `review_date` is on or after 2023-12-01. A review on 2023-12-01 counts as recent; one on 2023-11-30 does not. - An employee with no reviews at all meets the review condition. - An employee can have many reviews. One recent review is enough to exclude them, whatever their older reviews look like. - There are 1 to 10,000 employees and 0 to 100,000 reviews. - All dates are valid and none is after 2024-06-01. - Use the fixed date 2024-06-01, not the current date. ```hint Employees without reviews Make sure an employee with zero rows in `performance_reviews` still qualifies, and that one recent review excludes an employee even when they also have older ones. ```

Overview: Write a SQL query that finds employees with more than one year of tenure who have had no performance review in the last six months, measured from a fixed date. It tests date interval arithmetic, inclusive and exclusive boundaries, and filtering on the absence of related rows.

Lattice logo
Lattice
Nov 24, 2026
mediumData ScientistOtherData Manipulation (SQL/Python)
0
0

Using 2024-06-01 as today's date, return the employee_id and name of every employee who has been at the company for more than one year and has had no performance review within the last 6 months.

Input Table(s)

employees

ColumnTypeMeaning
employee_idINTEmployee id. Primary key.
nameVARCHAR(100)Employee name. NOT NULL.
hire_dateDATEDate the employee joined. NOT NULL.

performance_reviews

ColumnTypeMeaning
review_idINTReview id. Primary key.
employee_idINTEmployee who was reviewed. Foreign key to employees(employee_id).
review_dateDATEDate of the review. NOT NULL.

Output Contract

  • Columns, in this order: employee_id , name .
  • One row per qualifying employee, with no duplicates.
  • Sort by employee_id ascending.

Example

employees

employee_idnamehire_date
1Ana2020-03-15
2Ben2023-06-01
3Chen2022-01-10
4Dara2021-09-30
5Eli2024-02-01
6Fay2019-07-07

performance_reviews

review_idemployee_idreview_date
10132023-12-01
10242023-11-30
10342022-11-15
10462023-05-05
10562024-05-20

Expected result:

employee_idname
1Ana
4Dara

Ana has more than a year of tenure and no reviews at all. Dara's latest review (2023-11-30) is one day before the 6-month window opens. Ben has exactly one year of tenure, which is not more than one year. Chen's review on 2023-12-01 falls inside the window, Eli was hired too recently, and Fay was reviewed on 2024-05-20.

Constraints and Clarifications

  • More than one year of tenure means hire_date is strictly before 2023-06-01. An employee hired on 2023-06-01 does not qualify.
  • A review is within the last 6 months when review_date is on or after 2023-12-01. A review on 2023-12-01 counts as recent; one on 2023-11-30 does not.
  • An employee with no reviews at all meets the review condition.
  • An employee can have many reviews. One recent review is enough to exclude them, whatever their older reviews look like.
  • There are 1 to 10,000 employees and 0 to 100,000 reviews.
  • All dates are valid and none is after 2024-06-01.
  • Use the fixed date 2024-06-01, not the current date.