File tree Expand file tree Collapse file tree 2 files changed +44
-0
lines changed
Expand file tree Collapse file tree 2 files changed +44
-0
lines changed Original file line number Diff line number Diff line change @@ -49,6 +49,7 @@ Have a good contributing!
4949 - [ 619. Biggest Single Number] ( ./leetcode/easy/619.%20Biggest%20Single%20Number.sql )
5050 - [ 620. Not Boring Movies] ( ./leetcode/easy/620.%20Not%20Boring%20Movies.sql )
5151 - [ 1068. Product Sales Analysis I] ( ./leetcode/easy/1068.%20Product%20Sales%20Analysis%20I.sql )
52+ - [ 1075. Project Employees I] ( ./leetcode/easy/1075.%20Project%20Employees%20I.sql )
5253 - [ 1327. List the Products Ordered in a Period] ( ./leetcode/easy/1327.%20List%20the%20Products%20Ordered%20in%20a%20Period.sql )
5354 - [ 1378. Replace Employee ID With The Unique Identifier] ( ./leetcode/easy/1378.%20Replace%20Employee%20ID%20With%20The%20Unique%20Identifier.sql )
5455 - [ 1407. Top Travellers] ( ./leetcode/easy/1407.%20Top%20Travellers.sql )
Original file line number Diff line number Diff line change 1+ /*
2+ Question 1075. Project Employees I
3+ Link: https://leetcode.com/problems/project-employees-i/description/
4+
5+ Table: Project
6+
7+ +-------------+---------+
8+ | Column Name | Type |
9+ +-------------+---------+
10+ | project_id | int |
11+ | employee_id | int |
12+ +-------------+---------+
13+ (project_id, employee_id) is the primary key of this table.
14+ employee_id is a foreign key to Employee table.
15+ Each row of this table indicates that the employee with employee_id is working on the project with project_id.
16+
17+
18+ Table: Employee
19+
20+ +------------------+---------+
21+ | Column Name | Type |
22+ +------------------+---------+
23+ | employee_id | int |
24+ | name | varchar |
25+ | experience_years | int |
26+ +------------------+---------+
27+ employee_id is the primary key of this table. It's guaranteed that experience_years is not NULL.
28+ Each row of this table contains information about one employee.
29+
30+
31+ Write an SQL query that reports the average experience years of all the employees for each project, rounded to 2 digits.
32+
33+ Return the result table in any order.
34+ */
35+
36+ SELECT
37+ p .project_id ,
38+ ROUND(AVG (e .experience_years ), 2 ) AS average_years
39+ FROM Project AS p
40+ LEFT JOIN
41+ Employee AS e
42+ ON p .employee_id = e .employee_id
43+ GROUP BY p .project_id
You can’t perform that action at this time.
0 commit comments