查询语句,根据某个数值,自动生成查询行数,并排序,请大神帮助!

qq_42401900 2018-06-06 05:09:05
A表
ID NUM
1 4
2 5

结果集

序号 ID NUM
1 1 4
2 1 4
3 1 4
4 1 4
1 2 5
2 2 5
3 2 5
4 2 5
5 2 5

何解? 可以实现吗?
...全文
440 3 打赏 收藏 转发到动态 举报
写回复
用AI写文章
3 条回复
切换为时间正序
请发表友善的回复…
发表回复
qq_42401900 2018-06-07
  • 打赏
  • 举报
回复
谢谢你们!,都可以。
「已注销」 2018-06-06
  • 打赏
  • 举报
回复
with t1 as ( select 1 id, 4 num from dual union all select 2 id, 5 num from dual ) select t1.*,level from t1 connect by prior id = id and level <= num and prior dbms_random.value is not null;
zbdzjx 2018-06-06
  • 打赏
  • 举报
回复
with t1 as
(
select 1 id, 4 num from dual
union all
select 2 id, 5 num from dual
)
, t2 as
(
select rownum rn from dual connect by rownum <=  (select max(num) from t1)
)
select * from t1 a,t2 b
where a.num>=b.rn
order by a.id, b.rn

17,086

社区成员

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

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