title: QuerySyntaxException when using SQL EXCEPT and count(*)
body: <p>I have a situation in Hibernate where I need to get the count(*) on a SQL EXCEPT query. Below is the query (imitated my original code):</p>
  
  <pre><code>String query = """ 
                 select count(*) as totalCount 
                 from ( select distinct id from Employee 
                        where name like '%Roger% 
                        EXCEPT select distinct id from Manager ) Temporary
                 """
  </code></pre>
  
  <p>Now, when I say:</p>
  
  <pre><code>hibernateSession.createQuery(query);
  </code></pre>
  
  <p>The below exception is thrown:</p>
  
  <pre><code>org.hibernate.hql.ast.QuerySyntaxException: 
                      unexpected token: ( near line 1, column 36
  </code></pre>
  
  <p>My logs also show the below parsing errors when I catch the exception:</p>
  
  <pre><code>org.hibernate.hql.PARSER    line 1:36: unexpected token: (
  org.hibernate.hql.PARSER    line 14:315: unexpected token: EXCEPT
  org.hibernate.hql.PARSER    line 15:68: unexpected token: from
  </code></pre>
  
  <p>I cannot avoid the count, WHERE or EXCEPT.</p>