基本上看一种方法,将填充了错误数据的表与具有良好数据的表合并到"修复"它,但我想要的好数据有相当多的重复数据,我需要GROUP,以便我可以匹配。
所以在这种情况下简化了:
Customer_Records - Bad Data in SERIES_ID
| TITLE | SERIES_ID | TYPE |
| EX1 | 00000 | 1 |
| EX2 | 00009 | 1 |
| EX3 | 01234 | 2 |
Series_Records - Good data
| TITLE | SERIES_ID | SUBSERIES_ID |
| EX1 | 98555 | 00001
| EX1 | 98555 | 00002
| EX2 | 98764 | 00098
| EX2 | 98764 | 00108
因此,在此示例中,我尝试使用Series Record表中的SERIES_ID更新Customer Records表中的SERIES_ID。我有可以匹配的标题。
我尝试的内容如下:
merge into CUSTOMER_RECORDS CR
using (select TITLE, SERIES_ID from SERIES_RECORDS GROUP BY TITLE, SERIES_ID) SR
on (CR.TITLE = SR.TITLE)
when matched then
update set CR.SERIES_ID = SR.SERIES_ID;
当我这样做时,我得到了一个:
`A stable set of rows could not be got because of large dml activity or a non-deterministic where clause`
有什么想法吗?
答案 0 :(得分:0)
如果您关心的是series_id,并且series_records中的(title,series_id)总是相同的,无论subseries_id如何,那么您不能这样做:
merge into CUSTOMER_RECORDS CR
using (select DISTINCT TITLE, SERIES_ID from SERIES_RECORDS ) SR
on (CR.TITLE = SR.TITLE)
when matched then
update set CR.SERIES_ID = SR.SERIES_ID;