title: Group by query causing incorrect data to appear
body: <p>I'm trying to right a report to get a breakdown of all the ethnicities in my system by gender.</p>
  
  <p>I have this query that I thought was working, but all of the dates are the same in the query, which they are NOT in the individual tables. I think the group_by is causing an issue, but i'm not 100% and i'm not sure how to properly right this query.</p>
  
  <pre><code>SELECT f1.field_name, count(*) AS total
  FROM application_fields f1
  JOIN application_fields_values v1 ON v1.application_field_id = f1.id
  JOIN application_fields_values v2 ON v1.applicant_id = v2.applicant_id
  JOIN application_fields f2 ON v2.application_field_id = f2.id
  JOIN templates t ON f1.template_id = t.id
  JOIN template_fields tf ON f1.template_field_id = tf.id
  WHERE v1.field_value = 1
  AND v2.field_value = 1
  AND f2.field_name = 'Male'
  AND f1.field_name != 'Male'
  -- AND f1.created_at BETWEEN '2014-01-01' AND '2014-12-31'
  AND tf.id IN (9, 10, 11, 12, 13, 14, 15)
  GROUP BY f1.field_name
  ORDER BY f1.id;
  </code></pre>
  
  <p>This outputs:</p>
  
  <pre><code>FIELD_NAME          CREATED_AT              CREATED_AT          TOTAL
  Hispanic or Latino. 2013-06-20 02:35:56     2013-06-20 02:35:56   6
  Caucasion.          2013-06-20 02:35:56     2013-06-20 02:35:56   26
  African American.   2013-06-20 02:35:56     2013-06-20 02:35:56   25
  Native Hawaiian.    2013-06-20 02:35:56     2013-06-20 02:35:56   1
  Asian.              2013-06-20 02:35:56     2013-06-20 02:35:56   2
  American Indian.    2013-06-20 02:35:56     2013-06-20 02:35:56   2
  Two or more races . 2013-06-20 02:35:56     2013-06-20 02:35:56   1
  </code></pre>
  
  <p>I want to be able to filter this by date (as you can see in my commented out line) but that's not working correctly since all the dates are the same in this query when they most definitely are not in the tables themselves.</p>