如果我想这样操作怎么就不行了阿?select rownum,t.* from (select * from tablename order by age desc) t就报missing expression错误阿
你的oracle版本多少,早期版本不支持子查询中使用order by语句的
select rownum id,name,age from tab where rownum<=(select count(*) from tab);
select rownum as "id", name ,age from tab where rownum<=(select count(*) from tab) order by age;
select rownum as"id", name,age from tab where rownum<=(select count(*) from (select distinct * from tab)A) order by age;
select rownum id,t.* from tablename t order by age desc
select rownum as id,name,age from tablename; 这样就能实现你的功能. 你的这种做法select rownum,t.* from (select * from tablename order by age desc) t 查询出来的不是三个字段,而是rownum加上所有字段,并且是按降序的.
from tab
where rownum<=(select count(*) from tab);
from tab
where rownum<=(select count(*) from tab)
order by age;
from tab
where rownum<=(select count(*) from (select distinct * from tab)A)
order by age;
order by age desc
这样就能实现你的功能.
你的这种做法select rownum,t.* from (select * from tablename order by age desc) t
查询出来的不是三个字段,而是rownum加上所有字段,并且是按降序的.