甲骨文 11g。WASHINGTON DC 不在我的 STATES 表中,我无权添加它,但它需要在结果集中。我还希望 DC 在排序顺序中首先出现。
STATES
STATE_ID STATE_DESC
----------------------
FL FLORIDA
HI HAWAII
WY WYOMING
-----------------------------------------
select 'DC' state_id, 'WASHINGTON DC' state_desc from dual
union
select state_id, state_desc from states
order by
case state_id
when 'DC' then 'AAAA'
else state_desc
-------------------------
上面的查询产生以下错误消息:
ORA-01785: ORDER BY item must be the number of a SELECT-list expression
期望的结果
STATE_ID STATE_DESC
DC WASHINGTON DC
FL FLORIDA
HI HAWAII
WY WYOMING