<SYSTEM_TASK:>
Solve the following problem using Python, implementing the functions described below, one line at a time
<END_TASK>
<USER_TASK:>
Description:
 def count_results(cube, q):
 """ Get the count of records matching the query. """

    q = select(columns=[func.count(True)], from_obj=q.alias())
    return cube.engine.execute(q).scalar()