<aside> 💡

Project Overview:

This project involves analyzing the experience levels of employees associated with various projects. The goal is to calculate the average years of experience for all employees working on each project, rounded to two decimal places. The project demonstrates proficiency in SQL joins , aggregate functions, and data grouping.

</aside>


Problem Description:

Tables:

  1. Project:
  2. Employee:

The task was to determine the average experience of employees for each project, rounded to two decimal places.


Solution:

The query calculates the average years of experience for employees in each project by joining the Project and Employee tables and grouping the results by project_id.

SELECT p.project_id, ROUND(AVG(e.experience_years), 2) AS average_years
FROM Project p
JOIN Employee e ON p.employee_id = e.employee_id
GROUP BY p.project_id;


Explanation:

  1. Joining Tables:
  2. Calculating Average:
  3. Grouping:

Example Input and Output:

Input:

Project Table: