def antenna_metrics_hourly_query(table_name='%(table_name)s'):
    """
    Further aggregate user event counts by the hour of the day, therefore
    ignoring the day and week. Most importantly aggregate up to the
    antenna level for all users who are predicted to live inside an
    antennas coverage (home antenna).

    Inputs
    ------
    table_name : name of the table the query is supposed to run on,
                 defaulting to '%(table_name)s', i.e. no substitution

    Output
    ------
    Hourly antenna level aggregates of event counts,
    no more user ids.
    """
    query = """
        SELECT
          antenna_id,
          hour,
          SUM(og_sms) as og_sms,
          SUM(ic_sms) as ic_sms,
          SUM(og_calls) as og_calls,
          SUM(ic_calls) as ic_calls,
          SUM(og_vol) as og_vol,
          SUM(ic_vol) as ic_vol
        FROM %(table_name)s um
        JOIN table_user_home_antenna_df uha
        ON um.user_id = uha.user_id
        GROUP BY antenna_id, hour
    """
    return query % {'table_name': table_name}
