MERGE INTO tableA a USING (SELECT col1, col2, col3, col4 FROM tableB WHERE col3 = 1 ORDER BY col1) b ON (a.col1 = b.col1) WHEN NOT MATCHED THEN INSERT (col1, col2, col3, col4 ) VALUES (b.col1, b.col2, b.col3, b.col4 );