以下のクエリがあり、それを調整するためのより良い方法があるかどうか知りたいですか?
MERGE INTO target_table TARGET USING
(SELECT DISTINCT g1.column_name
FROM test_gtt1 g1,
test_gtt2 g2
WHERE g1.column_name = g2.column_name
AND g1.diff_id IS NULL
AND g2.diff_id IS NULL
UNION ALL
SELECT DISTINCT g1.column_name
FROM test_gtt1 g1,
test_gtt2 g2
WHERE
g1.column_name = g2.column_name
AND g1.diff_id = g2.diff_id
AND g1.diff_id IS NOT NULL
AND g2.diff_id IS NOT NULL
) SOURCE ON ( TARGET.column_name = SOURCE.column_name)
WHEN MATCHED THEN
UPDATE SET TARGET.column_name2 = 123;