O8i之前的版本不支持子查询中使用order by子句,所以一定要改成group by
select *
from (select *
from table a
group by a.num, a.col1, a.col2...)
where rownum<6;
select *
from (select *
from table a
group by a.num, a.col1, a.col2...)
where rownum<6;
按照你的SQL.我好象只能取最小的值
但我觉得这个问题用cursor来解决效率可能更高,在cursor定义中是可以使用order by的。
select *
from (select -num, col1, col2, col3, ...
from table a
group by -a.num, col1, col2, col3, ...)
where rownum < 6;
group by 后面必须加上所有select中的字段。另外,在程序中是很忌讳写select *这样的语法的,会给你的debug带来很多麻烦。asp中也可以使用cursor返回记录集,参见:
http://www.vbip.com/books/1861001789/chapter_1789_09.asp