我有很大的查询,我必须通过desc订购,但我不能这样做。我认为工会有问题,但我无法理解。
查询无需使用ORDER BY即可运行。
这是查询:
SELECT T.EMPLOYEE_NUMBER,
F.REG_ID,
F.DURATION_NETLINE,
F.FLIGHT_NUMBER,
F.DEPARTURE_DATE,
USER_LIFUS.NAME,
USER_LIFUS.SURNAME,
F.FORM_RESULT_STATUS,
T.LIEX_NUMBER,
F.IS_PC_FLIGHT,
F.IS_DC_FLIGHT,
FT.NAME FLIGHT_TYPE,
T.IS_RFLC,
F.IS_DC_FLIGHT,
F.LEG_ID
FROM TRAINEE T
INNER JOIN FLIGHT F
ON F.EVALUATED_EMP_NUM = T.EMPLOYEE_NUMBER
AND F.DEPARTURE_DATE >= T.LIFUS_START_DATE
AND (F.IS_SUBMITTED = 1 AND F.IS_DELETED = 0 AND F.IS_CANCELLED = 0)
AND F.IS_DC_FLIGHT = 0
AND F.IS_FC_FLIGHT = 0
--and f.leg_id <>0
INNER JOIN USER_LIFUS
ON USER_LIFUS.EMPLOYEE_NUMBER = F.INSTRUCTOR_EMP_NUM
INNER JOIN FLIGHT_TYPE FT
ON F.FLIGHT_TYPE_ID = FT.ID
WHERE T.EMPLOYEE_NUMBER = '088416'
UNION ALL
SELECT T.EMPLOYEE_NUMBER,F.REG_ID,
F.DURATION_NETLINE,
F.FLIGHT_NUMBER,
F.DEPARTURE_DATE,
USER_LIFUS.NAME,
USER_LIFUS.SURNAME,
F.FORM_RESULT_STATUS,
T.LIEX_NUMBER,
F.IS_PC_FLIGHT,
F.IS_DC_FLIGHT,
FT.NAME FLIGHT_TYPE,
T.IS_RFLC,
F.IS_DC_FLIGHT,
F.LEG_ID
FROM TRAINEE T
INNER JOIN FLIGHT F
ON F.EVALUATED_EMP_NUM = T.EMPLOYEE_NUMBER
AND F.DEPARTURE_DATE >= T.LIFUS_START_DATE
AND (F.IS_SUBMITTED = 1 AND F.IS_DELETED = 0 AND F.IS_CANCELLED = 0)
AND F.IS_DC_FLIGHT = 1
and f.is_fc_flight = 0
AND F.LEG_ID <> 0
INNER JOIN USER_LIFUS
ON USER_LIFUS.EMPLOYEE_NUMBER = F.INSTRUCTOR_EMP_NUM
INNER JOIN FLIGHT_TYPE FT
ON F.FLIGHT_TYPE_ID = FT.ID
WHERE T.EMPLOYEE_NUMBER = '123456'
当我添加
ORDER BY F.FLIGHT_NUMBER DESC
它给了我
ORA-00904
答案 0 :(得分:1)
假设您只添加了
dispatch_async
在查询的底部,您需要在两个联合查询之外添加它。
ORDER BY F.FLIGHT_NUMBER DESC
答案 1 :(得分:0)
这样做:
select temp.T.Employee_number,temp.F.REG_ID,temp.F.FLIGHT_NUMBER....
from ( --your query mentioned above-- ) temp
order by temp.F.FLIGHT_NUMBER desc;