title: ORMLite groupByRaw and groupBy issue on android SQLite db
body: <p>I have a SQLite table <em>content</em> with following columns:</p>
  
  <pre><code>-----------------------------------------------
  |id|book_name|chapter_nr|verse_nr|word_nr|word|
  -----------------------------------------------
  </code></pre>
  
  <p>the sql query </p>
  
  <pre><code>select count(*) from content where book_name = 'John'
  group by book_name, chapter_nr
  </code></pre>
  
  <p>in <a href="http://sqlitebrowser.org/" rel="nofollow noreferrer">DB Browser</a> returns 21 rows (which is the count of chapters)</p>
  
  <p>the equivalent with ORMLite android:</p>
  
  <pre><code>long count = getHelper().getWordDao().queryBuilder()
                          .groupByRaw("book_name, chapter_nr")
                          .where()
                          .eq("book_name", book_name)
                          .countOf(); 
  </code></pre>
  
  <p>returns 828 rows (which is the count of <em>verse numbers</em>)</p>
  
  <p>as far as I know the above code is translated to:</p>
  
  <pre><code>select count(*) from content
  where book_name = 'John'
  group by book_name, chapter_nr
  </code></pre>
  
  <p>result of this in DB Browser:</p>
  
  <pre><code>   | count(*)
  ------------
   1 | 828
   2 | 430
   3 | 653
  ...
   21| 542
  ---------
  21 Rows returned from: select count(*)...
  </code></pre>
  
  <p>so it seems to me that ORMLite returns the first row of the query as the result of <code>countOf()</code>.</p>
  
  <p>I've searched stackoverflow and google a lot. I found this <a href="https://stackoverflow.com/questions/12260781/how-to-use-the-ormlite-query-builder-to-get-the-total-records-in-a-table">question</a> (and more interestingly the answer)</p>
  
  <blockquote>
    <p>You can also count the number of rows in a custom query by calling the > countOf() method on the Where or QueryBuilder object.</p>
    
    <p>// count the number of lines in this custom query
    int numRows = dao.queryBuilder().where().eq("name", "Joe Smith").countOf();</p>
  </blockquote>
  
  <p>this is (correct me if I'm wrong) exactly what I'm doing, but somehow I just get the wrong number of rows.</p>
  
  <p>So... either I'm doing something wrong here or <code>countOf()</code> is not working the way it is supposed to.</p>
  
  <p>Note: It's the same with <code>groupBy</code> instead of <code>groupByRaw</code> (according to ORMLite documentation joining groupBy's should work)</p>
  
  <pre><code>...
  .groupBy("book_name")
  .groupBy("chapter_nr")
  .where(...)
  .countOf()
  </code></pre>
  
  <p><strong>EDIT</strong>: <code>getWordDao</code> returns from class <code>Word</code>:</p>
  
  <pre><code>@DatabaseTable(tableName = "content")
  public class Word { ... }
  </code></pre>