例如
no(非主键) m
1 100
2 100
2 200
1 100
2 100求出 sum(m)> 300 的记录来
要最效率的
no(非主键) m
1 100
2 100
2 200
1 100
2 100求出 sum(m)> 300 的记录来
要最效率的
解决方案 »
- oracle新手,求救
- 如何将Oracle某用户下所有表的依赖关系用树的形式列出来?
- 菜鸟问题,请高手帮忙解释一下这个rman备份,详细解释一下每一步的用途及原因,多谢!!!
- 如何得到字符串中最一个逗号和最后一个分号之间的子串内容。
- 询问一个sql 怎么写得更漂亮!
- 请给我以指导
- ====Oracle8.i安装问题:在Windows2000Server下,当即Setup.exe没有任何反应===
- 我把字段类型设为long,为什么插入还报错“文字字符串过长”
- 来鸟问题(在线给分)
- 关于审计的问题,如何审计才能得到数据!
- 什么是数据字典
- oracle10g修改了监听端口,sys用户在PL/SQL中能登陆,sqlplus中无法登陆?
from(
select no,m ,,sum()over(partition by no order by no)count
from table_name
)
where count>300
select no,m
from (select no,m,sum(m)over(partition by no) sm from table_name)
where sm > 300;
with ta as
(
select 1 as no ,100 as m from dual
union all
select 2 as no ,100 as m from dual
union all
select 2 as no ,200 as m from dual
union all
select 1 as no ,100 as m from dual
union all
select 2 as no ,100 as m from dual
)
select * from
(
select no,m,sum(m)over(partition by no) as num from taorder by dbms_random.value()
) where num>300;
from table1 a
where (select sum(m) from table1 where no=a.no)>300
from(
select no,m ,,sum()over(partition by no order by no)count
from table_name
)
where count>300
似乎不对啊这里只有no=1的,sum(m)》300,查询后的结果是:
no m
1 340
1 370
1 390
怎么得出了3行了,正常应该就是一行
no m
1 3901
select no,m
from (select no,m,sum(nvl(m,0))over(partition by no) sm from table_name)
where sm > 300;
这个效率最高