SQL Query to Find Employees Who Have Been with the Company for More Than 5 Years

To find the employees who have been with the company for more than 5 years, we can write a SQL query that uses the StartDate column in the table to filter the results.

Problem

Given a table of employee data, write a SQL query to find the employees who have been with the company for more than 5 years.
Example input:
| EmployeeID | FirstName | LastName  | StartDate   |
|------------|-----------|-----------|-------------|
| 1          | John      | Doe       | 1/1/2010    |
| 2          | Jane      | Smith     | 2/1/2011    |
| 3          | Bill      | Jones     | 3/1/2012    |
| 4          | Karen     | Williams  | 4/1/2013    |
Example output:
| EmployeeID | FirstName | LastName  | StartDate   |
|------------|-----------|-----------|-------------|
| 1          | John      | Doe       | 1/1/2010    |
| 2          | Jane      | Smith     | 2/1/2011    |

Solution

This solution is in SQL. Our A.I. can create solutions in multiple languages.
by sarastevens
SELECT * FROM Employee
WHERE StartDate < DATEADD(year, -5, GETDATE())

A.I. Evaluation of the Solution

This solution is correct and demonstrates a level of completeness. It solves the problem and uses a reasonable approach.

Evaluated at: 2022-11-12 00:16:33