帮忙把这段MSSQL的代码改成ORACLE的,谢谢。
时间:2011-09-14
来源:互联网
昨天在论坛提了个问,有位朋友写了如下代码,今天想把这段弄成ORACLE的,弄不出来呀。。。。来求助一下。。
SQL code
SQL code
create table tb(工艺序号 int,投入量 int,转换率 int) insert into tb select 1,20,1 insert into tb select 2, 0,2 insert into tb select 3, 0,1 insert into tb select 4,10,2 insert into tb select 5, 0,3 insert into tb select 6, 5,2 go ;with cte as( select *,投入量*转换率 as 应产出量 from tb where 工艺序号=1 union all select b.*,(b.投入量+a.应产出量)*b.转换率 from cte a inner join tb b on a.工艺序号=b.工艺序号-1 ) select * from cte /* 工艺序号 投入量 转换率 应产出量 ----------- ----------- ----------- ----------- 1 20 1 20 2 0 2 40 3 0 1 40 4 10 2 100 5 0 3 300 6 5 2 610 (6 行受影响) */ go drop table tb
作者: baronyang 发布时间: 2011-09-14
其实可以自己试着修改一下,语法差不多吧!
SQL code
1、* 要指定表前缀。
2、去掉列别名的as
试试看看行不行,有错误提示再说。
SQL code
create table tb(工艺序号 int,投入量 int,转换率 int) insert into tb select 1,20,1 insert into tb select 2, 0,2 insert into tb select 3, 0,1 insert into tb select 4,10,2 insert into tb select 5, 0,3 insert into tb select 6, 5,2 go ;with cte as( select tb.*,投入量*转换率 应产出量 from tb where 工艺序号=1 union all select b.*,(b.投入量+a.应产出量)*b.转换率 from cte a inner join tb b on a.工艺序号=b.工艺序号-1 ) select * from cte go drop table tb
1、* 要指定表前缀。
2、去掉列别名的as
试试看看行不行,有错误提示再说。
作者: hao1hao2hao3 发布时间: 2011-09-14
不是这里的错误。。。
是在union all下面的select里引用了with 的cte临时表。。
oralce里提示非法引用。。。。
SQL code
是在union all下面的select里引用了with 的cte临时表。。
oralce里提示非法引用。。。。
SQL code
union all select b.*,(b.投入量+a.应产出量)*b.转换率 from cte a inner join tb b on a.工艺序号=b.工艺序号-1 --是这句错了。。。不知道怎么改。。。
作者: baronyang 发布时间: 2011-09-14
临时表分两种,根据SESSION和TRANSACTION分。
CREATE GLOBAL TEMPORARY TABLE table_name ON COMMIT PRESERVE ROWS.
在SESSION结束是自动删除。
CREATE GLOBAL TEMPORARY TABLE table_name ON COMMIT DELETE ROWS
在提交COMMIT命令时候自动删除。
也是从其他地方找来的。。
CREATE GLOBAL TEMPORARY TABLE table_name ON COMMIT PRESERVE ROWS.
在SESSION结束是自动删除。
CREATE GLOBAL TEMPORARY TABLE table_name ON COMMIT DELETE ROWS
在提交COMMIT命令时候自动删除。
也是从其他地方找来的。。
作者: chcchb 发布时间: 2011-09-15
相关阅读 更多
热门阅读
-
office 2019专业增强版最新2021版激活秘钥/序列号/激活码推荐 附激活工具
阅读:74
-
如何安装mysql8.0
阅读:31
-
Word快速设置标题样式步骤详解
阅读:28
-
20+道必知必会的Vue面试题(附答案解析)
阅读:37
-
HTML如何制作表单
阅读:22
-
百词斩可以改天数吗?当然可以,4个步骤轻松修改天数!
阅读:31
-
ET文件格式和XLS格式文件之间如何转化?
阅读:24
-
react和vue的区别及优缺点是什么
阅读:121
-
支付宝人脸识别如何关闭?
阅读:21
-
腾讯微云怎么修改照片或视频备份路径?
阅读:28