Use date arithmetic to compute tenure and combine with analytical bucketing
We're reviewing compensation equity. For every active employee with a valid YYYY-MM-DD hire date, compute their tenure in years (as of 2026-01-01). Then bucket them: 'Less than 2 years', '2-4 years', '4-6 years', '6+ years'. Show the bucket, employee count, average salary, min salary, and max salary. I want to see if newer hires are paid differently.
Each hint you reveal reduces the XP you can earn. Try the query first.
Filter out employee 25 (MM/DD/YYYY format) and employee 42 (future hire date) since they have invalid dates for this analysis
Compute tenure: (julianday('2026-01-01') - julianday(hire_date)) / 365.25 or use date subtraction. In PostgreSQL: ('2026-01-01'::date - hire_date::date) / 365
Use CASE WHEN on the computed tenure to create buckets, then GROUP BY the bucket