title: Valid GROUP BY query doesn't work when combined with INSERT INTO on Oracle
body: <p>I'm trying to write an INSERT INTO that does a some DISTINCT/GROUP BY work.  The query runs perfectly fine as a select statement, but will not work if it's wrapped into an INSERT INTO.</p>
  
  <pre><code>INSERT INTO MasterRecords
    (BatchRecordRecordID, SourceID, BatchID)
  SELECT RecordID, SourceID, BatchID
  FROM (
      SELECT RecordID, BatchID, 101 AS SourceID
      FROM BatchRecords
      WHERE BatchID = 150
      GROUP BY RecordID, BatchID
  ) BR
  </code></pre>
  
  <p>This earns me:</p>
  
  <blockquote>
    <p>SQL Error: ORA-00979: not a GROUP BY expression</p>
  </blockquote>
  
  <p>But if I remove just the INSERT INTO code, it runs perfectly fine:</p>
  
  <pre><code>SELECT RecordID, SourceID, BatchID
  FROM (
      SELECT RecordID, BatchID, 101 AS SourceID
      FROM BatchRecords
      WHERE BatchID = 150
      GROUP BY RecordID, BatchID
  ) BR
  </code></pre>
  
  <p>Results:</p>
  
  <pre><code>3   101 150
  5   101 150
  6   101 150
  2   101 150
  4   101 150
  8   101 150
  7   101 150
  1   101 150
  </code></pre>
  
  <p>My assumption is that GROUP BY's are not allowed inside INSERT INTO select statements but I can find almost no documentation confirming this.</p>