CodePudding user response:
Select project. Project_id project. Employee_id, Max (employee. Experience_years) as experience_yearThe from project inner join the employee on the project. The employee_id=employee. Employee_id
Group by project. Project_id project. Employee_id
CodePudding user response:
The select c.p roject_id, a. * from the employee aJOIN the project c ON a.e mployee_id=c.e mployee_id
Where 1 & gt; (select count (*) from the employee where experience_years & gt; A.e xperience_years)
/*
Project_id employee_id name experience_years
Khaled 3 1 1
1 John 3 3
2 1 Khaled 3
*/
CodePudding user response:
The select c.p roject_id, c.e mployee_idThe from (select a. *, b., * rank () over (partition by Amy polumbo roject_id order by b.e xperience_years desc) rn
The from project a join employees b
On a.e mployee_id=b.e mployee_id) c
Where an rn=1