title: Merge insert with select statement
body: <p>This works for me</p>
  
  <pre><code>MERGE Table1 AS tgt
  USING
  (
      SELECT
          TOP 1
          *
      FROM
          Table2,
          (
              SELECT
                  itmid
              FROM
                  Table3
              WHERE
                  id = @id
          ) as a
      WHERE
          id = @id
  ) AS src
  ON ( tgt.id = src.id )
  WHEN MATCHED THEN
      UPDATE SET qty = qty + @qty
  WHEN NOT MATCHED THEN
      INSERT itmid
      VALUES itmid;
  </code></pre>
  
  <p>But when i change like this, its not working, showing error near last <code>select</code></p>
  
  <pre><code>MERGE Table1 AS tgt
  USING
  (
      SELECT
          TOP 1
          *
      FROM
          Table2
      WHERE
          id = @id
  ) AS src
  ON ( tgt.id = src.id )
  WHEN MATCHED THEN
      UPDATE SET qty = qty + @qty
  WHEN NOT MATCHED THEN
      INSERT itmid
      SELECT itmid FROM Table3 WHERE id = @id;
  </code></pre>