def METHOD_NAME(self):
    location_columns = self.spatial_unit.location_id_columns
    sql = f"""
    WITH unioned_table AS ({self.unioned_query.get_query()})
    SELECT {', '.join(location_columns)}, sum(introverted::integer)/count(*)::float as value FROM (
        SELECT
           {', '.join(f'A.{c} as {c}' for c in location_columns)},
           {' AND '.join(f'A.{c} = B.{c}' for c in location_columns)} as introverted
        FROM unioned_table as A
        INNER JOIN unioned_table AS B
              ON A.id = B.id
                 AND A.outgoing != B.outgoing
                 {make_where(self.direction.get_filter_clause(prefix="A"))}
    ) _
    GROUP BY {', '.join(location_columns)}
    ORDER BY {', '.join(location_columns)}
    """
    return sql