code: def select_sub(self, query, as_):
          
          if isinstance(query, QueryBuilder):
              bindings = query.get_bindings()
  
              query = query.to_sql()
          elif isinstance(query, basestring):
              bindings = []
          else:
              raise ArgumentError("Invalid subselect")
  
          return self.select_raw(
              "(%s) AS %s" % (query, self._grammar.wrap(as_)), bindings
          )
docs: Add a subselect expression to the query
  
          :param query: A QueryBuilder instance
          :type query: QueryBuilder
  
          :param as_: The subselect alias
          :type as_: str
  
          :return: The current QueryBuilder instance
          :rtype: QueryBuilder