ITPub博客

首页 > Linux操作系统 > Linux操作系统 > distinct与order by结合使用时要注意

distinct与order by结合使用时要注意

原创 Linux操作系统 作者:lawzjf 时间:2007-03-12 00:00:00 0 删除 编辑

SQL-99中,在select中使用distinct关键字后,在order by中出现的字段名称不能超过select子句的范围,如:

SQL> select distinct ename,sal from emp order by deptno;
select distinct ename,sal from emp order by deptno
*
ERROR at line 1:
ORA-01791: not a SELECTed expression

SQL> select distinct ename,sal from emp order by sal;

ENAME SAL
---------- ----------
SMITH 800
JAMES 950


来自 “ ITPUB博客 ” ,链接:https://blog.itpub.net/37724/viewspace-152576/ ,如需转载,请注明出处,否则将追究法律责任。

请登录后发表评论 登录
全部评论

注册时间:2008-01-18

  • 博文量
    279
  • 访问量
    990821