title: JOOQ select count distinct from group
body: <p>I am trying to count the number of records return by a group by select.</p>
  
  <p>This stackoverflow question summarises the different approaches well:</p>
  
  <p><a href="https://stackoverflow.com/questions/5146978/count-number-of-records-returned-by-group-by">Count number of records returned by group by</a></p>
  
  <p>I would like to use the solution: </p>
  
  <pre class="lang-sql prettyprint-override"><code>SELECT DISTINCT COUNT(*) OVER () AS TotalRecords
  FROM table
  GROUP BY column
  </code></pre>
  
  <p>How do I turn this into a JOOQ query?</p>
  
  <p>This is how I would do a simple count query in JOOQ:</p>
  
  <pre class="lang-java prettyprint-override"><code>Record record = jooq.select( TABLE.COLUMN.count() ).from( TABLE).fetchOne();
  
  return record.into( Long.class );
  </code></pre>
  
  <p>Is it possible to express the "DISTINCT COUNT(*) OVER () AS TotalRecords" in JOOQ syntax?</p>
  
  <p>James</p>