415. Employee Tenure Buckets

Easy HR Analytics Workforce Analytics
Query Rules
  • The query columns and order must match the expected result schema.
  • NULL values should be handled appropriately where applicable.
  • The grader compares output values and sorting order to evaluate.

Schema Browser

Click a table's header to toggle expand/collapse.
locations
3 cols
departments
3 cols
employees
6 cols
orders
6 cols

Reference Solution

Expected SQL
WITH tenure AS (SELECT emp_id, (JULIANDAY('2025-12-11') - JULIANDAY(hire_date)) / 365.0 AS years_tenure FROM employees) SELECT CASE WHEN years_tenure < 1 THEN '<1 year' WHEN years_tenure < 3 THEN '1-3 years' WHEN years_tenure < 5 THEN '3-5 years' ELSE '5+ years' END AS tenure_bucket, COUNT(*) AS employee_count FROM tenure GROUP BY tenure_bucket ORDER BY employee_count DESC;
SQL Editor
Ctrl+Enter to run
Console Output

Console Terminal

Write your query and click "Run Query" (Ctrl + Enter) to see results and testcase validation.