def daily_features_query(table_name='%(table_name)s'):
    """
    Create daily features which are part of the final feature set.
    For outgoing and incoming events separately, the percentages of
    number of events (or total duration) happening on the weekend or holidays
    are being calculated. These features are bound between 0 and 1.

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

    Output
    ------
    Partial final features dataframe which holds features
    calculated on the weekends over the whole weeks.
    """
    query = """
        SELECT
          antenna_id,
          -- og week ratios (weekend/holidays over all week)
          SUM(IF(week_part IN ('weekend', 'holiday'), og_calls, NULL))/
            SUM(og_calls) as og_calls_week_ratio,
          SUM(IF(week_part IN ('weekend', 'holiday'), og_sms, NULL))/
            SUM(og_sms) as og_sms_week_ratio,
          SUM(IF(week_part IN ('weekend', 'holiday'), og_vol, NULL))/
            SUM(og_vol) as og_vol_week_ratio,
          -- ic week ratios (weekend/holidays over all week)
          SUM(IF(week_part IN ('weekend', 'holiday'), ic_calls, NULL))/
            SUM(ic_calls) as ic_calls_week_ratio,
          SUM(IF(week_part IN ('weekend', 'holiday'), ic_sms, NULL))/
            SUM(ic_sms) as ic_sms_week_ratio,
          SUM(IF(week_part IN ('weekend', 'holiday'), ic_vol, NULL))/
            SUM(ic_vol) as ic_vol_week_ratio
        FROM %(table_name)s
        GROUP BY antenna_id
    """
    return query % {'table_name': table_name}
