title: Rails: group and count sql query include zero's
body: <p>I'm able to run this query to generate a hash of Regions and group by answer (including zero count):</p>
  
  <p><code>Region.includes(:answers).group("regions.region").count("answers")</code></p>
  
  <p>produces:</p>
  
  <pre><code>{"blar"=&gt;0, "East"=&gt;0, "East Midlands"=&gt;11, "London"=&gt;8, "North East"=&gt;0, "North West"=&gt;0, "Northern Ireland"=&gt;0, "Rest of World"=&gt;89, "Scotland"=&gt;0, "South East"=&gt;0, "South West"=&gt;0, "Wales"=&gt;0, "West Midlands"=&gt;0, "Yorkshire and the Humber"=&gt;0}
  </code></pre>
  
  <p>However when I want this result (to include count zeros) for a particular question, it only displays a hash of the regions with an answer.</p>
  
  <p>Query:</p>
  
  <pre><code>Region.includes(:answers).where("answers.question_id = 14").group("regions.region").count("answers")
  </code></pre>
  
  <p>produces:</p>
  
  <pre><code>{"East Midlands"=&gt;3, "London"=&gt;1, "Rest of World"=&gt;4}
  </code></pre>
  
  <p>I understand the query will be selecting only answers for question_id, so this gives the given output but I've tried many different queries (including LEFT OUT JOINS) and been unable to get the desired result.</p>
  
  <p>For reference:</p>
  
  <p>Region has_many :answers</p>
  
  <p>Answer belongs_to :region</p>
  
  <p>Answer belongs_to :question</p>
  
  <p>Thanks</p>