SQL
All Top 50 SQL Interview Questions#26
Calculate Average Experience Per Project in SQL
EasyInterview Question #26
Given `project` (project_id, employee_id) and `employee` (employee_id, experience_years), write a query to report the average experience years of all employees for each project, rounded to 2 decimal places.
Input Table: project & employee
5 rows preview| project_id | employee_id | experience_years |
|---|---|---|
| 1 | 1 | 3 |
| 1 | 2 | 2 |
| 1 | 3 | 1 |
| 2 | 1 | 3 |
| 2 | 4 | 6 |
Expected Output Structure2 rows
| project_id | average_years |
|---|---|
| 1 | 2 |
| 2 | 4.5 |
Interview Context
Asked frequently in data analyst and business analyst technical rounds. Focus on clean filtering, optimal indexing usage, and unambiguous column selection.
PostgreSQL 15
Ready to execute
Click "Run Query" or press Ctrl + Enter to test your query.
Output will be verified against the test dataset.