def as_nested_sql(self):
    "\n        Perform the same functionality as the as_sql() method, returning an\n        SQL string and parameters. However, the alias prefixes are bumped\n        beforehand (in a copy -- the current query isn't changed), and any\n        ordering is removed if the query is unsliced.\n\n        Used when nesting this query inside another.\n        "
    obj = self.query.clone()
    if ((obj.low_mark == 0) and (obj.high_mark is None) and (not self.query.distinct_fields)):
        obj.clear_ordering(True)
    nested_sql = obj.get_compiler(connection=self.connection).as_sql(subquery=True)
    if (nested_sql == ('', ())):
        raise EmptyResultSet
    return nested_sql
Perform the same functionality as the as_sql() method, returning an
SQL string and parameters. However, the alias prefixes are bumped
beforehand (in a copy -- the current query isn't changed), and any
ordering is removed if the query is unsliced.

Used when nesting this query inside another.
def as_nested_sql(self):
    "\n        Perform the same functionality as the as_sql() method, returning an\n        SQL string and parameters. However, the alias prefixes are bumped\n        beforehand (in a copy -- the current query isn't changed), and any\n        ordering is removed if the query is unsliced.\n\n        Used when nesting this query inside another.\n        "
    obj = self.query.clone()
    if ((obj.low_mark == 0) and (obj.high_mark is None) and (not self.query.distinct_fields)):
        obj.clear_ordering(True)
    nested_sql = obj.get_compiler(connection=self.connection).as_sql(subquery=True)
    if (nested_sql == (, ())):
        raise EmptyResultSet
    return nested_sql