File tree 1 file changed +30
-0
lines changed
1 file changed +30
-0
lines changed Original file line number Diff line number Diff line change
1
+ -- Table: Project
2
+ -- +-------------+---------+
3
+ -- | Column Name | Type |
4
+ -- +-------------+---------+
5
+ -- | project_id | int |
6
+ -- | employee_id | int |
7
+ -- +-------------+---------+
8
+ -- (project_id, employee_id) is the primary key of this table.
9
+ -- employee_id is a foreign key to Employee table.
10
+ -- Each row of this table indicates that the employee with employee_id is working on the project with project_id.
11
+
12
+ -- Table: Employee
13
+ -- +------------------+---------+
14
+ -- | Column Name | Type |
15
+ -- +------------------+---------+
16
+ -- | employee_id | int |
17
+ -- | name | varchar |
18
+ -- | experience_years | int |
19
+ -- +------------------+---------+
20
+ -- employee_id is the primary key of this table. It's guaranteed that experience_years is not NULL.
21
+ -- Each row of this table contains information about one employee.
22
+
23
+ -- Write an SQL query that reports the average experience years of all the employees for each project, rounded to 2 digits.
24
+ -- Return the result table in any order.
25
+
26
+ select Project .project_id ,
27
+ round(avg (Employee .experience_years ), 2 ) as average_years
28
+ from Project left join Employee
29
+ on Project .employee_id = Employee .employee_id
30
+ group by Project .project_id ;
You can’t perform that action at this time.
0 commit comments