def as_sql(self, qn, connection):
        "Return the aggregate, rendered as SQL."

        if hasattr(self.col, 'as_sql'):
            field_name = self.col.as_sql(qn, connection)
        elif isinstance(self.col, (list, tuple)):
            field_name = '.'.join([qn(c) for c in self.col])
        else:
            field_name = self.col

        params = {
            'function': self.sql_function,
            'field': field_name
        }
        params.update(self.extra)

        return self.sql_template % params
dataset/ETHPy150Open AppScale/appscale/AppServer/lib/django-1.2/django/db/models/sql/aggregates.py/Aggregate.as_sql/original