728x90
๐ป ๋ฌธ์ ์ฃผ์ : Project Employees I - LeetCode
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
๐ป ๋ฌธ์
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 order.
- ๊ฐ ํ๋ก์ ํธ๋ณ ๋ชจ๋ ์ง์๋ค์ ํ๊ท ๊ฒฝ๋ ฅ ์ฐ์๋ฅผ ๊ตฌํ์์ค. ํ๊ท ์ ์์์ ๋ ์๋ฆฌ๊น์ง ์ถ๋ ฅ๋์ด์ผ ํ๋ฉฐ, ๊ฒฐ๊ณผ ํ ์ด๋ธ ์์๋ ์๊ด ์์ต๋๋ค.
๐ป ์ฝ๋ ๋ฐ ํ์ด
select pj.project_id, round(avg(experience_years), 2) as average_years
from Project pj
join Employee ep on pj.employee_id = ep.employee_id
group by pj.project_id
728x90
๋ฐ์ํ
'SQL > LeetCode' ์นดํ ๊ณ ๋ฆฌ์ ๋ค๋ฅธ ๊ธ
[LeetCode][SQL50] #19. Queries Quality and Percentage (0) | 2023.11.15 |
---|---|
[LeetCode][SQL50] #18. Percentage of Users Attended a Contest (0) | 2023.11.15 |
[LeetCode][SQL50] #16. Average Selling Price (0) | 2023.11.14 |
[LeetCode][SQL50] #15. Not Boring Movies (2) | 2023.11.13 |
[LeetCode][SQL50] #14. Confirmation Rate (0) | 2023.11.13 |