title: merge on target table by comparing source and target table both
body: <p>Do we have provision of matching source and target table both in oracle</p>
  <p>I have three condition:</p>
  <ol>
  <li>when source and target matches then update on condition</li>
  <li>When New data in source which is not in target then add the record.</li>
  <li>When data is not there in source but in target. Then update the flag in target table.</li>
  </ol>
  <p>Please note: Source table is refreshed every day.</p>
  <p>I am able to do step 1 and step 2 in merge like below</p>
  <pre><code>merge into target as t using Source as S
        On t.pk1 = s.pk1 and t1.pk2 = s.pk2
  when matched and t.normalKey &lt;&gt; s.NormalKey --Step 1
      then update t.normalKey = s.NormalKey
  when not matched 
      then insert (t.field) values (s.field) --Step 2
  Step 3-- ?
  </code></pre>
  <p>There is a way of handling this in sql server. as below
  I am trying to figure out same way of using 'By' clause in Snowflake.</p>
  <p>Below is the example we do in sqlserver.</p>
  <pre><code>MERGE &lt;target_table&gt; [AS TARGET]
  USING &lt;table_source&gt; [AS SOURCE]
  ON &lt;search_condition&gt;
  [WHEN MATCHED 
     THEN &lt;merge_matched&gt; ]
  [WHEN NOT MATCHED [BY TARGET]
     THEN &lt;merge_not_matched&gt; ]
  [WHEN NOT MATCHED BY SOURCE
     THEN &lt;merge_matched&gt; ];
  </code></pre>
  <p>My final solution will be to use another merge/update statement.
  First Merge to handle step 1 and 2.</p>
  <p>and another Update just to handle step 3.</p>
  <p>Or do we have a better way.</p>