Bo's Oracle Station

查看: 1312|回复: 0

关联子查询的组函数改写

[复制链接]

1005

主题

1469

帖子

1万

积分

管理员

Rank: 9Rank: 9Rank: 9

积分
12012
发表于 2020-9-27 22:09:03 | 显示全部楼层 |阅读模式
  1. SELECT department_id, employee_id, salary
  2. FROM EMPLOYEES e
  3. WHERE 1 =
  4. (SELECT COUNT(DISTINCT salary)
  5. FROM EMPLOYEES
  6. WHERE e.department_id = department_id
  7. AND e.salary <= salary);


  8. select a.department_id, e.employee_id , e.salary
  9. from
  10. (select  department_id, max(salary)  maxsal
  11. from employees
  12. group by department_id) a , employees e
  13. where a.department_id =e.department_id
  14. and a.maxsal=e.salary ;
复制代码


回复

使用道具 举报

您需要登录后才可以回帖 登录 | 立即注册

本版积分规则

QQ|手机版|Bo's Oracle Station   

GMT+8, 2024-11-23 16:02 , Processed in 0.041978 second(s), 25 queries .

快速回复 返回顶部 返回列表