#91. [LeetCode / MySQL] 1075. Project Employees I

문제

 

입력 코드

1. 

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

 

2. 

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

 

코드 설명

#SELECT #ROUND #AVG #SUM #COUNT #JOIN #GROUP BY

 

 

문제 출처

 

Project Employees I - LeetCode

Can you solve this real interview question? Project Employees I - Table: Project +-------------+---------+ | Column Name | Type | +-------------+---------+ | project_id | int | | employee_id | int | +-------------+---------+ (project_id, employee_id) is th

leetcode.com