table name : mytable
--------------------------------------------------------
id col_1 col_2 ...............scNum ........
-----------------------------------------------------------
1 xxx xxx ............ 90 .........
.............................
--------------------------------------------------------------------------------数据量大。
如上 要求某列 的最大值 最优化的 方法是什么?不要 用 max 等的哦用的是 oracle 数据库。
--------------------------------------------------------
id col_1 col_2 ...............scNum ........
-----------------------------------------------------------
1 xxx xxx ............ 90 .........
.............................
--------------------------------------------------------------------------------数据量大。
如上 要求某列 的最大值 最优化的 方法是什么?不要 用 max 等的哦用的是 oracle 数据库。
from 表
order by 字段 desc
select top 1 字段 from 表 order by 字段 desc
不用max就用上面的top ... order by ... desc
如果不是你最终要的,请给出测试数据和想要的结果
求最大值 的处理, 就max 和 top..order by desc 2 中处理办法了?
还有没有 其他 处理 方法呢?
道不同,不足....
下面是个简单的例子
SQL> select * from t1;
ID1 ID2
---------- ----------
1 1
1 2
2 2
2 2
3 2
4 1
5 1
6 1
7 1
8 1
10 rows selectedSQL> select id1 from
2 (
3 select t1.*,row_number() over(order by id1 desc) rn
4 from t1
5 )
6 where rn = 1
7 ;
ID1
----------
8