鉴于此表:
SELECT
t1.MODEL as MODEL,
t1.DATE as DATE
t1.RESULT as RESULT_1,
t1.SECTION as SECTION_1,
t2.RESULT as RESULT_2,
t2.SECTION as SECTION_2
FROM table t1
INNER JOIN table t2
ON t1.DATE = t2.DATE AND t1.MODEL = t2.MODEL
WHERE t2.section > t1.section AND
t2.result < t1.result
我想确保每个部分(对于相同的日期/型号),结果始终大于或等于 任何 前一部分。
e.g。如果第7行的结果小于第6行的结果,我需要将第7行设置为等于第6行的结果。
同样,如果第5行的结果小于第2行的结果,我需要将第5行的结果设置为第2行的结果。
我能够找到这样的情况,其中较高部分的值低于使用自连接的前一部分,如下所示:
MODEL DATE SECTION_1 RESULT_1 SECTION_2 RESULT_2
AABBCC 1/1/2001 3 42.2 4 35.4
AABBCC 1/1/2001 6 95.3 7 76.5
产生以下内容:
MERGE INTO table new
USING (
SELECT
t1.MODEL as MODEL,
t1.DATE as DATE
t1.RESULT as RESULT_1,
t1.SECTION as SECTION_1,
t2.RESULT as RESULT_2,
t2.SECTION as SECTION_2
FROM table t1
INNER JOIN table t2
ON t1.DATE = t2.DATE AND t1.MODEL = t2.MODEL
WHERE t2.section > t1.section AND
t2.result < t1.result
) old
ON (new.DATE = old.DATE AND new.section > old.section)
WHEN MATCHED THEN
UPDATE
SET new.result = old.result;
我试图合并这样的数据:
from skimage.restoration import denoise_nl_means,denoise_wavelet
但是我收到以下错误:
错误报告 - SQL错误:ORA-30926:无法获得稳定的一组 源表中的行 30926. 00000 - “无法在源表中获得稳定的行集” *原因:由于dml较大,无法获得稳定的行集 活动或非确定性的where子句。 *操作:删除任何非确定性where子句并重新发出dml。
答案 0 :(得分:0)
MERGE INTO table new
USING (
SELECT MODEL,
DATE,
RESULT,
SECTION
FROM (
SELECT
t1.MODEL as MODEL,
t1.DATE as DATE,
MAX(t1.RESULT) OVER (PARTITION BY t1.MODEL ORDER BY t1.SECTION) as RESULT,
t1.SECTION as SECTION,
t1.RESULT as OLD_RESULT
FROM table t1)
WHERE OLD_RESULT != RESULT
) old
ON (new.DATE = old.DATE AND new.section = old.section and new.MODEL = old.MODEL )
WHEN MATCHED THEN
UPDATE
SET new.result = old.result;