Oracle使用count max condition创建表为select

我有一个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).

相关文章

发表回复

您的电子邮箱地址不会被公开。 必填项已用 * 标注