def count(self):
    'Return a count of rows this Query would return.\n\n        This generates the SQL for this Query as follows::\n\n            SELECT count(1) AS count_1 FROM (\n                SELECT <rest of query follows...>\n            ) AS anon_1\n\n        .. versionchanged:: 0.7\n            The above scheme is newly refined as of 0.7b3.\n\n        For fine grained control over specific columns\n        to count, to skip the usage of a subquery or\n        otherwise control of the FROM clause,\n        or to use other aggregate functions,\n        use :attr:`~sqlalchemy.sql.expression.func`\n        expressions in conjunction\n        with :meth:`~.Session.query`, i.e.::\n\n            from sqlalchemy import func\n\n            # count User records, without\n            # using a subquery.\n            session.query(func.count(User.id))\n\n            # return count of user "id" grouped\n            # by "name"\n            session.query(func.count(User.id)).\\\n                    group_by(User.name)\n\n            from sqlalchemy import distinct\n\n            # count distinct "name" values\n            session.query(func.count(distinct(User.name)))\n\n        '
    col = sql.func.count(sql.literal_column('*'))
    return self.from_self(col).scalar()
Return a count of rows this Query would return.

This generates the SQL for this Query as follows::

    SELECT count(1) AS count_1 FROM (
        SELECT <rest of query follows...>
    ) AS anon_1

.. versionchanged:: 0.7
    The above scheme is newly refined as of 0.7b3.

For fine grained control over specific columns
to count, to skip the usage of a subquery or
otherwise control of the FROM clause,
or to use other aggregate functions,
use :attr:`~sqlalchemy.sql.expression.func`
expressions in conjunction
with :meth:`~.Session.query`, i.e.::

    from sqlalchemy import func

    # count User records, without
    # using a subquery.
    session.query(func.count(User.id))

    # return count of user "id" grouped
    # by "name"
    session.query(func.count(User.id)).\
            group_by(User.name)

    from sqlalchemy import distinct

    # count distinct "name" values
    session.query(func.count(distinct(User.name)))
def count(self):
    'Return a count of rows this Query would return.\n\n        This generates the SQL for this Query as follows::\n\n            SELECT count(1) AS count_1 FROM (\n                SELECT <rest of query follows...>\n            ) AS anon_1\n\n        .. versionchanged:: 0.7\n            The above scheme is newly refined as of 0.7b3.\n\n        For fine grained control over specific columns\n        to count, to skip the usage of a subquery or\n        otherwise control of the FROM clause,\n        or to use other aggregate functions,\n        use :attr:`~sqlalchemy.sql.expression.func`\n        expressions in conjunction\n        with :meth:`~.Session.query`, i.e.::\n\n            from sqlalchemy import func\n\n            # count User records, without\n            # using a subquery.\n            session.query(func.count(User.id))\n\n            # return count of user "id" grouped\n            # by "name"\n            session.query(func.count(User.id)).\\\n                    group_by(User.name)\n\n            from sqlalchemy import distinct\n\n            # count distinct "name" values\n            session.query(func.count(distinct(User.name)))\n\n        '
    col = sql.func.count(sql.literal_column('*'))
    return self.from_self(col).scalar()