RT,打比方说一个已经按照Salary降序排序的表格SAGA(NO varchar2(10),Salary varchar2(10)),如何确定i,使得Salary属性的前i条和为一固定值1500.或者说如何提取前i项属性和为1500的最小的i。用SQL语句来写
解决方案 »
- 求高手解决 在centOS下安装oracle 出错 帮忙请指导下 谢谢
- 该如何崇table中找出每个部门最接近系统日期的那一笔资料
- 在装Oracle10g时 错误提示:”指定的SID本机上已存在 请指定一个不同的SID“该怎么办啊???
- 请高手帮助sql语句
- dba_tables表中的一行为NUM_ROWS数值为何不与该表用SELECT COUNT(*)得到的行数同步?
- ◎◎◎◎ 一个存有 bfile 数据的表的同步/迁移?????
- SQL command not properly ended的错误
- 请问一个批量插入数据的问题,小弟刚入门,请多指教
- 请问ORACLE9I要用到多少硬盘空间呢
- distinct与group by?
- timesten 的TNS name
- ORA-01219:数据库未打开:仅允许在固定表/视图中查询
select 'a', 1000 from dual
union all select 'b', 300 from dual
union all select 'c', 200 from dual
union all select 'd', 100 from dual
union all select 'e', 100 from dual
union all select 'f', 100 from dual;SQL>
SQL> select rn
2 from (
3 select rn, no, salary, sum(salary) over(order by rn) total_salary
4 from (
5 select no, salary, rownum rn
6 from saga
7 order by salary desc
8 ) x
9 )
10 where total_salary = 1500;
RN
----------
3
from (select no,
sum(salary) over(order by salary desc) as sum_value,
rank() over(order by salary desc) as i
from saga) t
where t.sum_value = 1500;