Oracle create table as select with count max condition(Oracle 创建表为 select with count max 条件)
问题描述
我遇到了 Oracle 问题,这是我的选择:
I've got an Oracle problem, here is my select:
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 开发人员说我:
this query gives me one generic error with no explanation. SQL Developer say me:
"从命令第 7 行开始出错:[...] 错误报告:
SQL 命令:创建表
失败:警告:执行完成,但有警告
"Error starting at line 7 in command: [...] Error report:
SQL Command: create table
Failed: Warning: execution completed with warning"
但是创建了表,里面的数据好像是正确的.
but create the table and the data inside seems to be correct.
一些提示?
推荐答案
每当您在具有 NULL 的列上使用函数时,Oracle 都会在 CREATE TABLE 语句中发出失败:警告:执行完成并出现警告".当您使用 CASE WHEN 或 DECODE 并且不使用默认值来处理 NULL(例如 ELSE 0)时,通常会发生这种情况.这也是 https://forums.oracle 上所述相同问题的解决方案.com/forums/thread.jspa?threadID=723332.
Oracle issues the "Failed: Warning: execution completed with warning" in a CREATE TABLE statement whenever you use a function on a column with NULLs. This often happens when you use a CASE WHEN or DECODE and don't use a default to take care of the NULLs (e.g., ELSE 0). This is also the solution to the same problem stated on https://forums.oracle.com/forums/thread.jspa?threadID=723332.
为避免出现问题:确保不要在 CREATE TABLE AS 中具有 NULL 的列上使用函数(例如,max、sum).
To avoid problems: make sure you don't use a function (e.g., max, sum) on a column with NULLs in a CREATE TABLE AS.
这篇关于Oracle 创建表为 select with count max 条件的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持编程学习网!
本文标题为:Oracle 创建表为 select with count max 条件
- 使用 Oracle PL/SQL developer 生成测试数据 2021-01-01
- 导入具有可变标题的 Excel 文件 2021-01-01
- 如何将 SonarQube 6.7 从 MySQL 迁移到 postgresql 2022-01-01
- 在SQL中,如何为每个组选择前2行 2021-01-01
- 如何使用 pip 安装 Python MySQLdb 模块? 2021-01-01
- 更改自动增量起始编号? 2021-01-01
- 以一个值为轴心,但将一行上的数据按另一行分组? 2022-01-01
- 如何将 Byte[] 插入 SQL Server VARBINARY 列 2021-01-01
- 远程 mySQL 连接抛出“无法使用旧的不安全身份验证连接到 MySQL 4.1+"来自 XAMPP 的错误 2022-01-01
- SQL 临时表问题 2022-01-01
