def get_dlp_results_sql(project_id, dataset_id, table_id, min_count=0) -> str:
    """ Generate sql to query the DLP results table: https://cloud.google.com/dlp/docs/querying-findings
        and counts the number of finding in each field,info-type, likelihood grouping
    :param project_id: Project Id
    :param dataset_id: Dataset
    :param table_id: Table
    :return:a sql query that generates a result set with the following columns [field_name, info_type_name, likelihood, count_total]
    """

    return """SELECT
        locations.record_location.field_id.name AS field_name,
        info_type.name as info_type_name,
        likelihood as likelihood,
        COUNT(*) AS count_total
    FROM {}.{}.{},
        UNNEST(location.content_locations) AS locations
    GROUP BY
        locations.record_location.field_id.name,
        info_type.name,
        likelihood
    HAVING count_total > {}
    """.format(
        project_id, dataset_id, table_id, min_count
    )