SELECT
h.host_id,
h.host_name,
h.country,
h.hosts_source,
hi.info_type as hi_info_type,
hi.info_value as hi_info_value,
hi.part_month as hi_part_month
FROM (
SELECT DISTINCT
h_inner.host_id,
h_inner.host_name,
h_inner.country,
h_inner.hosts_source
FROM hosts h_inner
INNER JOIN hosts_info hi_check ON h_inner.host_id = hi_check.hosts_id
AND hi_check.info_type = #{params.dataType}
AND CAST(hi_check.info_value AS SIGNED) >= #{params.dataStart}
AND CAST(hi_check.info_value AS SIGNED) #{params.dataEnd}
AND h_inner.country IN
(SELECT country_name FROM country_info WHERE country_group_name = #{params.region})
AND h_inner.update_dt = #{params.searchTime}
AND h_inner.owner_by = #{params.userId}
AND h_inner.tenant_id = #{params.tenantId}
LIMIT #{page.size} OFFSET #{page.current}
) h
INNER JOIN hosts_info hi ON h.host_id = hi.hosts_id
AND hi.part_month = #{params.searchTime}