2011-09-10 3 views
0

내가 뭘 잘못하고 있니?hiredate 주문 오름차순

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> 
+2

같은 당신의 마지막 질문 http://stackoverflow.com/questions/7373117/asending-order-for-hiredate를 참조 싶어하고 SQL 구문을 읽고 명령의 순서를 적어 두십시오. – Mark

+2

간단한 구문 오류 인 질문이 너무 많습니다. 오라클 설명서는 포괄적이고 온라인이며 무료입니다. 더 이상의 질문을 게시하기 전에 그것을 읽으십시오. 여기에서 찾으십시오. http://download.oracle.com/docs/cd/B19306_01/server.102/b14200/toc.htm – APC

답변

1

순서는 내림차순 원하지 않는다면이 필요하지 않도록 마지막

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

상승은 기본이다 (당신은 또한 "오 데르"없습니다 "질서"를했다) 제공 그러나 가독성을 위해 좋음

0
select ename, job, hiredate from emp where hiredate between '20-FEB-81' AND '01 MAY-81' order by hiredate acs 
2
  1. ORDER BY 절은 WHERE
  2. ORDER BY 절은 당신이 SELECT 목록에 컬럼에 적용되지 않는 별도의 clause-- 후 제공됩니다.
  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 
관련 문제