Self Join Employees Table for Dates
Find employees who joined before their manager.
sql
SELECT e.name FROM employees e JOIN employees m ON e.manager_id = m.id WHERE e.joined_at < m.joined_at;
This query performs a self-join on the "employees" table to compare the "joined_at" date of each employee with the "joined_at" date of their respective manager, returning the names of employees who joined earlier.
PromptDB can make mistakes. Please double-check responses.