#NEWLINE# def as_sql( self , qn = None ) : #NEWLINE# #INDENT# '\n        Creates the SQL for this query. Returns the SQL string and list of\n        parameters.\n        ' #NEWLINE# if ( qn is None ) : #NEWLINE# #INDENT# qn = self . quote_name_unless_alias #NEWLINE# #UNINDENT# sql = ( 'SELECT %s FROM (%s) subquery' % ( ', ' . join ( [ aggregate . as_sql ( qn , self . connection ) for aggregate in self . query . aggregate_select . values ( ) ] ) , self . query . subquery ) ) #NEWLINE# params = self . query . sub_params #NEWLINE# return ( params , params )