为雇佣者升序

发布于 2024-12-04 10:45:43 字数 705 浏览 1 评论 0原文

我做错了什么?

SQL> select ename, job, oder by (ascending order)hiredate  from emp where hiredate between '20-FEB-81' AND '01-MAY-81';
select ename, job, oder by (ascending order)hiredate  from emp where hiredate between '20-FEB-81' AND '01-MAY-81'
                    *
ERROR at line 1:
ORA-00923: FROM keyword not found where expected


SQL>

桌子

SQL> select ename, job, hiredate  from emp where hiredate between '20-FEB-81' AND '01 MAY-81';

ENAME      JOB       HIREDATE
---------- --------- ---------
BLAKE      MANAGER   01-MAY-81
JONES      MANAGER   02-APR-81
ALLEN      SALESMAN  20-FEB-81
WARD       SALESMAN  22-FEB-81

SQL>

What am I doing wrong?

SQL> select ename, job, oder by (ascending order)hiredate  from emp where hiredate between '20-FEB-81' AND '01-MAY-81';
select ename, job, oder by (ascending order)hiredate  from emp where hiredate between '20-FEB-81' AND '01-MAY-81'
                    *
ERROR at line 1:
ORA-00923: FROM keyword not found where expected


SQL>

Table

SQL> select ename, job, hiredate  from emp where hiredate between '20-FEB-81' AND '01 MAY-81';

ENAME      JOB       HIREDATE
---------- --------- ---------
BLAKE      MANAGER   01-MAY-81
JONES      MANAGER   02-APR-81
ALLEN      SALESMAN  20-FEB-81
WARD       SALESMAN  22-FEB-81

SQL>

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

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

发布评论

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

评论(3

葵雨 2024-12-11 10:45:43
  1. ORDER BY 子句位于 WHERE 子句之后
  2. ORDER BY 子句是一个单独的子句 - 您不会将其应用于SELECT 列表。
  3. 语法是 ORDER BY column_name [ASC|DESC]

所以你想要类似的东西

SQL> select ename, job, hiredate
  2    from emp
  3   where hiredate between to_date( '20-FEB-81', 'DD-MON-RR' ) and
  4                          to_date( '01-MAY-81', 'DD-MON-RR' )
  5   order by hiredate asc;

ENAME      JOB       HIREDATE
---------- --------- ----------
ALLEN      SALESMAN  1981-02-20
WARD       SALESMAN  1981-02-22
JONES      MANAGER   1981-04-02
BLAKE      MANAGER   1981-05-01
  1. The ORDER BY clause comes after the WHERE clause
  2. The ORDER BY clause is a separate clause-- you don't apply it to the column in the SELECT list.
  3. The syntax is ORDER BY column_name [ASC|DESC]

So you'd want something like

SQL> select ename, job, hiredate
  2    from emp
  3   where hiredate between to_date( '20-FEB-81', 'DD-MON-RR' ) and
  4                          to_date( '01-MAY-81', 'DD-MON-RR' )
  5   order by hiredate asc;

ENAME      JOB       HIREDATE
---------- --------- ----------
ALLEN      SALESMAN  1981-02-20
WARD       SALESMAN  1981-02-22
JONES      MANAGER   1981-04-02
BLAKE      MANAGER   1981-05-01
盛夏已如深秋| 2024-12-11 10:45:43

顺序排在最后(您也有“order”而不是“order”)

select ename, job, hiredate  
from emp where hiredate between '20-FEB-81' AND '01-MAY-81'
order by hiredate  asc

升序是默认值,因此除非您想要降序,否则不需要它,但它有利于可读性

order comes last (you also had "oder" not "order")

select ename, job, hiredate  
from emp where hiredate between '20-FEB-81' AND '01-MAY-81'
order by hiredate  asc

ascending is the default so unless you want descending it is not needed but it is good for readability

遗失的美好 2024-12-11 10:45:43
select ename, job, hiredate  from emp where hiredate between '20-FEB-81' AND '01 MAY-81' order by hiredate acs
select ename, job, hiredate  from emp where hiredate between '20-FEB-81' AND '01 MAY-81' order by hiredate acs
~没有更多了~
我们使用 Cookies 和其他技术来定制您的体验包括您的登录状态等。通过阅读我们的 隐私政策 了解更多相关信息。 单击 接受 或继续使用网站,即表示您同意使用 Cookies 和您的相关数据。
原文