Study - Problems(IT)/LeetCode - SQL

1075. Project Employees I

Dev.D 2024. 11. 10. 04:59

* Problem

Write an SQL query that reports the average experience years of all the employees for each project, rounded to 2 digits.

Return the result table in any orde

Explanation: The average experience years for the first project is 
(3 + 2 + 1) / 3 = 2.00 and for the second project is (3 + 2) / 2 = 2.50

 

* Solution 

# Write your MySQL query statement below
select  a.project_id project_id,
            round(avg(b.experience_years),2) average_years
   from Project a
   left join Employee b
      on a.employee_id = b.employee_id
    group by a.project_id

 

'Study - Problems(IT) > LeetCode - SQL' 카테고리의 다른 글

1174.Immediate Food Delivery2  (2) 2024.11.17
1193.Monthly Transactions  (0) 2024.11.16
1211.Queries Quality and Percentage  (0) 2024.11.15
1633. Percentage of Users Attended a Contest  (1) 2024.11.14
1251.Average Selling Price  (0) 2024.11.08