已知开始页,怎么得到结束页?

cqchi 2015-06-20 10:15:14
已知开始页为
1
3
4
5
6
7
14
16
怎么求得结束页,我知道除第一条记录外,结束页等于开始页-1,用SQL怎么写出来呢?高分求教!
...全文
152 3 打赏 收藏 转发到动态 举报
写回复
用AI写文章
3 条回复
切换为时间正序
请发表友善的回复…
发表回复
碧水幽幽泉 2015-06-24
  • 打赏
  • 举报
回复
这个可以~

with tmp as
(select 1 s_page from dual union all
select 3 from dual union all
select 4 from dual union all
select 5 from dual union all
select 6 from dual union all
select 7 from dual union all
select 14 from dual union all
select 16 from dual)
select t.s_page,
       nvl(lead(t.s_page) over(order by s_page) - 1, t.s_page) as e_page
  from tmp t
jdsnhan 2015-06-23
  • 打赏
  • 举报
回复
with tmp as
(select 1 s_page from dual union all
select 3 from dual union all
select 4 from dual union all
select 5 from dual union all
select 6 from dual union all
select 7 from dual union all
select 14 from dual union all
select 16 from dual)
select t.s_page,
       nvl(lead(t.s_page) over(order by s_page) - 1, t.s_page) as e_page
  from tmp t
chengccy 2015-06-22
  • 打赏
  • 举报
回复
with tmp (s_page) as
(select 1 from dual union all
select 3 from dual union all
select 4 from dual union all
select 5 from dual union all
select 6 from dual union all
select 7 from dual union all
select 14 from dual union all
select 16 from dual)
select t.s_page,
       nvl(lead(t.s_page) over(order by s_page) - 1, t.s_page) as e_page
  from tmp t

17,089

社区成员

发帖
与我相关
我的任务
社区描述
Oracle开发相关技术讨论
社区管理员
  • 开发
  • Lucifer三思而后行
  • 卖水果的net
加入社区
  • 近7日
  • 近30日
  • 至今
社区公告
暂无公告

试试用AI创作助手写篇文章吧