我无法在 oracle 9i 中使用 minus 关键字!

发布于 2024-08-24 03:15:20 字数 209 浏览 8 评论 0原文

select  salary from employees order by salary desc
MINUS
select  salary from employees where rownum<10 order by salary desc;

我无法将 order by 与 MINUS 一起使用,它表示 sql 命令未正确结束。 请建议!

select  salary from employees order by salary desc
MINUS
select  salary from employees where rownum<10 order by salary desc;

I am unable to use order by with MINUS ,it says sql command not properly ended.
Please suggest!

如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。

扫码二维码加入Web技术交流群

发布评论

需要 登录 才能够评论, 你可以免费 注册 一个本站的账号。

评论(1

你爱我像她 2024-08-31 03:15:20

考虑到业务问题似乎是什么(显示工资不在工资前十名的员工的工资),我认为分析将是一个值得考虑的选择:

select salary 
  from (select salary,
               rank() over (order by salary) as salary_rank
          from employees
       )
 where salary_rank > 10
 order by salary;

使用分析也只会扫描EMPLOYEES 一次,而原始查询会扫描两次。

Given what the business question seems to be (show the salaries of employees where the salary is not in the top ten of salaries) I would think analytics would be a choice worth considering:

select salary 
  from (select salary,
               rank() over (order by salary) as salary_rank
          from employees
       )
 where salary_rank > 10
 order by salary;

Using analytics would also only scan EMPLOYEES once, whereas the original query would scan it twice.

~没有更多了~
我们使用 Cookies 和其他技术来定制您的体验包括您的登录状态等。通过阅读我们的 隐私政策 了解更多相关信息。 单击 接受 或继续使用网站,即表示您同意使用 Cookies 和您的相关数据。
原文