社区所有版块导航
Python
python开源   Django   Python   DjangoApp   pycharm  
DATA
docker   Elasticsearch  
aigc
aigc   chatgpt  
WEB开发
linux   MongoDB   Redis   DATABASE   NGINX   其他Web框架   web工具   zookeeper   tornado   NoSql   Bootstrap   js   peewee   Git   bottle   IE   MQ   Jquery  
机器学习
机器学习算法  
Python88.com
反馈   公告   社区推广  
产品
短视频  
印度
印度  
Py学习  »  DATABASE

2020-11-14-Mysql(领扣-分组求值)

隐约喜欢萌萌哒 • 3 年前 • 221 次点击  
image.png
with x as 
(
select 
Name, Salary,DepartmentId,
dense_rank() over(partition by DepartmentId  order by Salary desc)  as result
from 
Employee) 
select 
Department.Name AS Department ,
x.Name AS   Employee,
x.Salary AS Salary
from
Department join x on  x.DepartmentId = Department.Id  
where x.result = 1
image.png
select s.name as department,t.name as Employee,t.salary from (
select name,salary,departmentid,
dense_rank() over(partition by departmentid order by salary desc) as rn 
from 
Employee) t
join department s on t.departmentid = s.id 
where rn <=3
Python社区是高质量的Python/Django开发社区
本文地址:http://www.python88.com/topic/99295
 
221 次点击