依次求002~009,003~009,004~009,005~009,006~009,007~009,008~009 ,009~009...........中的最大值 select tt.ID,tt.NO,tt.q,(select max(t.q) from test t where tt.id=t.id and t.no>tt.no) maxq from test tt; 解决方案 » 免费领取超大流量手机卡,每月29元包185G流量+100分钟通话, 中国电信官方发货 select t.*, nvl((select distinct first_value(no) over(order by q desc) from test2 t1 where t1.id = t.id and t1.no > t.no),no) no1, nvl(max(q) over(partition by id order by no rows between 1 FOLLOWING and UNBOUNDED FOLLOWING),q) maxqfrom test2 torder by id,noSQL> 6 /ID NO Q NO1 MAXQ--- --- ---- --- ----------1 001 5 003 101 002 9 003 101 003 10 005 81 004 3 005 81 005 8 006 71 006 7 008 71 007 1 008 71 008 7 009 61 009 6 009 62 100 65 102 322 101 25 102 322 102 32 103 82 103 8 104 32 104 3 104 314 rows selected win7成功安装oracle,但是无法用评论pl/sql登陆 ora-03115错误 这样的语句该怎么写? 存储过程报错,请高手解决 请教这种多级扩展表的查询语句该怎么写》 这个过程怎么改效率更好? 为什么NVL不起作用呢? 如何将这些t-sql语句改为plsql? RENAME命令改表名字后,表名自动变成了一串奇怪的字符 关于数据库事务特性和它的隔离级别的困惑? 如何将SQL2000库导入到LINUX下的ORACLE中 請問:一個date類型的字段,怎樣選取時間段?3Q
nvl((select distinct first_value(no) over(order by q desc) from test2 t1 where t1.id = t.id and t1.no > t.no),no) no1,
nvl(max(q) over(partition by id order by no rows between 1 FOLLOWING and UNBOUNDED FOLLOWING),q) maxq
from test2 t
order by id,noSQL>
6 /ID NO Q NO1 MAXQ
--- --- ---- --- ----------
1 001 5 003 10
1 002 9 003 10
1 003 10 005 8
1 004 3 005 8
1 005 8 006 7
1 006 7 008 7
1 007 1 008 7
1 008 7 009 6
1 009 6 009 6
2 100 65 102 32
2 101 25 102 32
2 102 32 103 8
2 103 8 104 3
2 104 3 104 314 rows selected