mysql兩表連接查詢

有兩張表:

employee 表

這裏寫圖片描述

department 表

這裏寫圖片描述

要求找出每個部門工資最高的人的 姓名、所在部門、工資

查詢結果如圖,

這裏寫圖片描述

sql語句爲:

select department.name Department,employee.name Employee,max(salary) Salary from employee 
inner JOIN department on employee.department = department.id group by department
發表評論
所有評論
還沒有人評論,想成為第一個評論的人麼? 請在上方評論欄輸入並且點擊發布.
相關文章