有两个表:
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该怎么写呢??新手,实在不懂,求教大侠们,谢谢啦!!
解决方案 »
- 我现在将一份控制文件备份成三份,不知道为什么会报错?
- 如何让一行数据变成多行数据
- 物化视图(Materialize View)与一般视图(View)有何区别
- 在建立表时,使用逻辑主键作为PK呢,还是用是物理主键作为PK呢?
- ORACLE 监听
- 菜鸟级提问,请各位老大看看这条SQL为什么可以执行
- 谁能告诉我这些SQL语句要怎么写呢?oracle数据库
- 问大家Oracle9i和Oracle10g是什么关系?后面的字母i和g分别表示什么 ?是什么单词的缩写?知者进来领分!
- 定义某列为默认值的SQL 建表语句
- 《Oracle9i实务管理讲座--系统核心篇》这本书大家觉得怎么样?
- 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;