加入收藏 | 设为首页 | 会员中心 | 我要投稿 核心网 (https://www.hxwgxz.com/)- 科技、建站、经验、云计算、5G、大数据,站长网!
当前位置: 首页 > 站长百科 > 正文

Oracle使用count max condition创建表为select

发布时间:2021-05-16 14:14:59 所属栏目:站长百科 来源:网络整理
导读:我有一个Oracle问题,这是我的选择: create table new_table as selectidprod as product_id,descr as descriptionfrom old_table p where updateNum = (select max(updateNum) from old_table pp where pp.idprod = p.idprod); 此查询给出了一个通用错误,没

我有一个Oracle问题,这是我的选择:

create table new_table as 
select
idprod as product_id,descr as description
from old_table p where updateNum = (select max(updateNum) from old_table pp where pp.idprod = p.idprod);

此查询给出了一个通用错误,没有解释. SQL Developer说我:

“Error starting at line 7 in command: […] Error report:
SQL Command: create table
Failed: Warning: execution completed with warning”

但是创建表并且里面的数据似乎是正确的.

一些提示?

无论何时在具有NULL的列上使用函数,Oracle都会在CREATE TABLE语句中发出“失败:警告:执行完成且出现警告”.当您使用CASE WHEN或DECODE并且不使用默认值来处理NULL(例如,ELSE 0)时,通常会发生这种情况.这也是 https://forums.oracle.com/forums/thread.jspa?threadID=723332中所述相同问题的解决方案.

为避免出现问题:请确保在CREATE TABLE AS中的NULL列上不使用函数(例如,max,sum).

(编辑:核心网)

【声明】本站内容均来自网络,其相关言论仅代表作者个人观点,不代表本站立场。若无意侵犯到您的权利,请及时与联系站长删除相关内容!

    热点阅读