def get_district_subject_distribution_values(subject_name, ids, table_code):
    distribution = report_config.get_distribution(subject_name)
    statistics_type = distribution[0]

    greater_where = qa.Where("sum", symbol=">")
    less_equal_where = qa.Where("sum", symbol="<=")

    basic_where = [exam_where]
    if subject_name == "总分":
        dimen_table = table_config.get_stu_sum_table(table_code)
        if statistics_type == report_config.COUNT:
            basic_where.append(qa.Where("count", value=distribution[2]))
    else:
        dimen_table = table_config.get_stu_dimen_table(table_code)
        subject_where.value = get_subject_id_by_name(subject_name)
        basic_where.append(subject_where)

    normal_cell = qa.Cell("COUNT(*)", dimen_table, [[greater_where, less_equal_where]] + basic_where)
    if statistics_type == report_config.ALL:
        greater_equal_where = qa.Where("sum", symbol=">=")
        extra_cell = qa.Cell("COUNT(*)", dimen_table, [[greater_equal_where, less_equal_where]] + basic_where)
        row1 = qa.RowSeriesCell(extra_cell, ids[0:1])
        row2 = qa.RowSeriesCell(normal_cell, ids[1:])
        return qa.DataRows.combine_col_rows(row1, row2)
    else:
        row = qa.RowSeriesCell(normal_cell, ids)
        return row.get_values()
def get_distributions(subject_name):
    distributions = report_config.get_distribution(subject_name)
    ids = []
    names = []
    for distribution in distributions[1]:
        ids_t, names_t = get_ranges(distribution[0], distribution[1], distribution[2])
        ids.extend(ids_t)
        names.extend(names_t)
    if distributions[0] == report_config.ALL:
        start = distributions[1][0][0]
        step = distributions[1][0][2]
        names[0] = "[%d, %d]" % (start, start + step)
    return ids, names