Using 2026-06-30 as today: return name and hiredate of employees hired in the last 6 months. Table definitions (from…
SQLLevel: IntermediateDates and time
Using 2026-06-30 as today: return name and hire_date of employees hired in the last 6 months.
Table definitions (from the source exercise):
CREATE TABLE employees(emp_id INTEGER PRIMARY KEY, name TEXT, department_id INTEGER, manager_id INTEGER, salary INTEGER, hire_date TEXT, job_title TEXT, gender TEXT);
Hints
- Define one output row and the source-table keys.
- Check duplicates, NULLs and the order of filtering and aggregation.
Answer
Approach: hire_date >= DATE_SUB of the fixed date.
SELECT name, hire_date
FROM employees
WHERE hire_date >= DATE_SUB('2026-06-30', INTERVAL 6 MONTH);
The source uses SQLite with a MySQL compatibility layer. Date and string functions are dialect dependent; the query is preserved as published.
Source and licence: SQL Practice Lab — Ebrahim Sharifi · MIT