用sql語句如何找出數據庫中按某字段大小排列的
select * from ( select * from cpu order by cpuname) where rownum <6
*
ERROR 位於第 1 行:
ORA-00907: 缺少右括號
給子查詢起個別名試試
select * from ( select * from cpu order by cpuname) a where rownum <6
Order by 不能加
確實有點怪,除去ORDERBY就可以了
oracle中在子查詢中是不能用order by 語句的,不用嘗試了
不過可以用游標來實現的。
SQL> select * from ( select * from tab order by tname) where rownum < 6;
TNAME TABTYPE CLUSTERID
------------------------------ ------- ----------
A TABLE
B TABLE
C TABLE
D TABLE
E TABLE
我的Oracle就支持Oracle 8.1.7
你的ORACLE版本是什麼?
改用臨時表吧。tw.WINgwIT.cOM
create table temp as ( select rownum row_no, * from cpu order by cpuname);
select * from temp where row_no < 6;
drop table temp;
From:http://tw.wingwit.com/Article/program/Oracle/201311/18836.html