有两个表:
A表:branch_no amt
-----------------
1843 3
1728 2
8888 4B表:branch_no index_no name
---------------------------
1728 1 a
1728 2 b
8888 1 c
8888 2 c
8888 3 d
8888 4 e
1843 1 a
1843 2 b
1843 3 e现在要生成新表C:
branch_no index_no name
----------------------------
1728 3 a
1728 4 b
8888 5 c
8888 6 c
8888 7 d
8888 8 e
1843 4 a
1843 5 b
1843 6 e新表C中,某个branch_no的index_no字段是在B表中这个branch_no所对应的最大index_no值基础上增长的,比如表B中branch_no=1728的,index_no最大是2,生成表C时,branch_no=1728的记录,index_no就在2的基础上增长,因为表B中branch_no=1728的记录有两条,所以表C中branch_no=1728的,Index_no就从3增长到4。这个用oracle该怎么写呢??新手,实在不懂,求教大侠们,谢谢啦!!
A表:branch_no amt
-----------------
1843 3
1728 2
8888 4B表:branch_no index_no name
---------------------------
1728 1 a
1728 2 b
8888 1 c
8888 2 c
8888 3 d
8888 4 e
1843 1 a
1843 2 b
1843 3 e现在要生成新表C:
branch_no index_no name
----------------------------
1728 3 a
1728 4 b
8888 5 c
8888 6 c
8888 7 d
8888 8 e
1843 4 a
1843 5 b
1843 6 e新表C中,某个branch_no的index_no字段是在B表中这个branch_no所对应的最大index_no值基础上增长的,比如表B中branch_no=1728的,index_no最大是2,生成表C时,branch_no=1728的记录,index_no就在2的基础上增长,因为表B中branch_no=1728的记录有两条,所以表C中branch_no=1728的,Index_no就从3增长到4。这个用oracle该怎么写呢??新手,实在不懂,求教大侠们,谢谢啦!!
解决方案 »
- 求SQL!
- oracle启动报错.ORA-01033: ORACLE initialization or shutdown in progress
- 请求关于动态游标的使用问题(附代码)
- Oracle教学视频下载
- 安装Oracle9i Release 2 Services for MTS 9.2.0.7.0 后 oracle 服务器不能启动
- 看来这个问题要移到本版才能解决了?!
- Oracle数据检索的初级问题。(再线等)
- 关于oracle错误代码的问题?
- 大虾请指点
- 问题:如何删去一个表的主键 ~~~50
- ORA-12516:TNS:监听程序找不到符合协议堆栈要求的可用处理程序
- 使用SYS_CONNECT_BY_PATH遇到“返回字符串超长”如何处理
select b.branch_no,b.index_no+a.cou index_no,b.name from b,(select count(*) as cou,branch_no from b group by branch_no) a where a.branch_no=b.branch_no;