Tenure in days as of March 31, 2026: department 21
Level: JuniorTopic: NULL traps50 XP
Instructions
For the employees (dismissed ones included) of the department with department_id = 21 with salary at least 70000, select id, name and tenure_days, the tenure in days: for dismissed employees, the difference of the dates fired_at − hired_at; for active ones (fired_at is NULL), the difference between the date March 31, 2026 and hired_at. Row order does not matter.
Hints
Each next one is more detailed and costs more
Query
Result
Click Run to see the query result, or Check to submit your solution.
Dataset schema
Exactly oneZero or oneZero or more
Table relationships
- N:1Many-to-one
employees.→department_id departments.id - N:1Many-to-one
employees.→manager_id employees.id - N:1Many-to-one
departments.→parent_id departments.id - N:1Many-to-one
salary_history.→employee_id employees.id
Table data
PostgreSQL
Select a table in the diagram or list to view its rows.