Oracle 创建表为 select with count max 条件

Oracle create table as select with count max condition(Oracle 创建表为 select with count max 条件)
本文介绍了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 条件的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持编程学习网!

本站部分内容来源互联网,如果有图片或者内容侵犯您的权益请联系我们删除!

相关文档推荐

SQL to Generate Periodic Snapshots from Transactions Table(用于从事务表生成定期快照的SQL)
MyBatis support for multiple databases(MyBatis支持多个数据库)
Oracle 12c SQL: Missing column Headers in result(Oracle 12c SQL:结果中缺少列标题)
SQL query to find the number of customers who shopped for 3 consecutive days in month of January 2020(查询2020年1月连续购物3天的客户数量)
How to get top 10 data weekly (This week, Previous week, Last month, 2 months ago, 3 month ago)(如何每周获取前十大数据(本周、前一周、上个月、2个月前、3个月前))
Select the latest record for an Id per day - Oracle pl sql(选择每天ID的最新记录-Oracle pl SQL)