title: Remove extra GROUP BY in SQL query in Django ORM
body: <p>I have the following model:</p>
  
  <pre><code>class Statistics(models.Model):
      game_id = models.IntegerField(db_column='gameid', primary_key=True)
      time = models.DateTimeField()
      servers = models.IntegerField()
      users = models.IntegerField()
  </code></pre>
  
  <p>I have legacy postgre database with custom database function <code>datediff_hours</code>. 
  To use this function in django I create the following class:</p>
  
  <pre><code>from django.db.models import Func
  
  
  class DateDiffHoursFunc(Func):
      function = 'datediff_hours'
  </code></pre>
  
  <p>Now I construct the actual query:</p>
  
  <pre><code>from django.db.models import Sum, Value, F
  
  query = Statistics.objects.values('time').filter(game_id=1).\
          annotate(users_sum=Sum('users', distinct=True)).\
          annotate(timestamp=DateDiffHoursFunc(Value(datetime(2016, 5, 26)), F('time'))).\
          values('users_sum', 'timestamp')
  </code></pre>
  
  <p>And the query I get:</p>
  
  <pre><code>&gt;&gt;&gt; print(query.query)
  
  SELECT 
       SUM(`statistics`.`users`) AS `users_sum`, 
       datediff_hours(2013-04-01 00:00:00, `statistics`.`time`) AS `timestamp`
  FROM `statistics` WHERE `statistics`.`gameid` = 12 
  GROUP BY `statistics`.`time`, datediff_hours(2013-04-01 00:00:00, `statistics`.`time`) 
  ORDER BY NULL
  </code></pre>
  
  <p>But what I need grouping only by <code>time</code>, like this:</p>
  
  <pre><code>SELECT 
       SUM(`statistics`.`users`) AS `users_sum`, 
       datediff_hours(2013-04-01 00:00:00, `statistics`.`time`) AS `timestamp`
  FROM `statistics` WHERE `statistics`.`gameid` = 12 
  GROUP BY `statistics`.`time`) 
  ORDER BY NULL
  </code></pre>
  
  <p>How can I restrict grouping only by <code>time</code>? </p>