def put_condition_on_query(query, condition):
    """
    To generate a query that wraps the output of some query with some given conditions

    :param query: (str) base query
    :param condition: (str) where condition
    :return:
        (str) new query
    """
    query = query.strip()
    if query[-1] == ";":
        query = query[:-1]
    return f"SELECT * FROM ({query}) as cond_table {condition}"