我做错了什么?
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>
答案 0 :(得分:2)
ORDER BY
子句位于WHERE
子句ORDER BY
子句是一个单独的子句 - 您不会将其应用于SELECT
列表中的列。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 :(得分:1)
订单来到最后(你也有“oder”而非“订单”)
select ename, job, hiredate
from emp where hiredate between '20-FEB-81' AND '01-MAY-81'
order by hiredate asc
升序是默认值,因此除非您想要降序,否则不需要它,但它有利于可读性
答案 2 :(得分:0)
select ename, job, hiredate from emp where hiredate between '20-FEB-81' AND '01 MAY-81' order by hiredate acs