merge
,正如你所说,可能是一种选择。
之前:
SQL> select * From test;
CIF FLAG
---------- ----
120 SF
120 NA
165 SF
165
158 MF
158
6 rows selected.
合并:
SQL> merge into test a
2 using (select b.cif, max(b.flag) flag
3 from test b
4 group by b.cif
5 ) x
6 on (a.cif = x.cif)
7 when matched then update set
8 a.flag = x.flag
9 where a.flag is null;
2 rows merged.
之后:
SQL> select * From test;
CIF FLAG
---------- ----
120 SF
120 NA
165 SF
165 SF
158 MF
158 MF
6 rows selected.
SQL>