def as_sql(self, qn=None):
        if qn is None:
            qn = self.quote_name_unless_alias
        sql = ('SELECT %s FROM (%s) subquery' % (
            ', '.join([
                aggregate.as_sql(qn, self.connection)
                for aggregate in self.query.aggregate_select.values()
            ]),
            self.query.subquery)
        )
        params = self.query.sub_params
        return (sql, params)
Returns the left table if one was specified, otherwise the first
dataset/ETHPy150Open AppScale/appscale/AppServer/lib/django-1.2/django/db/models/sql/compiler.py/SQLAggregateCompiler.as_sql--crossover with--dataset/ETHPy150Open ambitioninc/django-query-builder/querybuilder/query.py/Join.get_left_table