title: Subselect fails, but as view it works
body: <p>I was hoping to run a single query and get results from that. However, MSSQL complains about a syntax error near the <code>GROUP</code> key word.
  I was hoping to do the following.</p>
  
  <pre><code>  SELECT COUNT(*) AS cnt,Field_2
      FROM (SELECT DISTINCT Field_1, Field_2 
              FROM Table_1)
  GROUP BY Field_2 
    HAVING COUNT(*) &gt; 1
  </code></pre>
  
  <p>Instead I had to create a view, View_1, with the query</p>
  
  <pre><code>SELECT DISTINCT Field_1, Field_2 
    FROM Table_1
  </code></pre>
  
  <p>And then do a</p>
  
  <pre><code>  SELECT COUNT(*) AS cnt, Field_2
      FROM View_1
  GROUP BY Field_2 
    HAVING COUNT(*) &gt; 1
  </code></pre>
  
  <p>The question is why, to my mind it is essentially the same SQL.</p>
  
  <p>Note: Field, table and view names have been changed to protect the innocent. ;-)</p>