select count(distinct tmci.company_info_id)
from tc_mch_company_info tmci
left join tc_mch_merchant tmm on tmm.company_info_id=tmci.company_info_id
left join `tc_mch_merchant_report` tmmr ON tmci.`company_info_id` = tmmr.`company_info_id`
left join (
select GROUP_CONCAT(tag.name) as tagsName, GROUP_CONCAT(tag.id) as tagsId, tagCompany.`company_info_id` as companyInfoId
from `tc_mch_tag_company` tagCompany
left join `tc_mch_tag` tag on tagCompany.`tag_id` = tag.id group by tagCompany.`company_info_id`
) companyTag on tmci.`company_info_id` = companyTag.companyInfoId
left join tc_mch_agents tma on tma.agent_id=tmm.agent_id
where tmci.mechanism_id='1188'
and ((tmm.`check_status` = 1 and tmm.merchant_type != 1) or tmm.`merchant_id` is null)
select count(distinct tmci.company_info_id) ,count( tmm.company_info )from tc_mch_company_info tmci left join tc_mch_merchant tmm on tmm.company_info_id=tmci.company_info_id left join tc_mch_merchant_report tmmr ON tmci.company_info_id = tmmr.company_info_id left join ( select GROUP_CONCAT(tag.name) as tagsName, GROUP_CONCAT(tag.id) as tagsId, tagCompany.company_info_id as companyInfoId from tc_mch_tag_company tagCompany left join tc_mch_tag tag on tagCompany.tag_id = tag.id group by tagCompany.company_info_id ) companyTag on tmci.company_info_id = companyTag.companyInfoId left join tc_mch_agents tma on tma.agent_id=tmm.agent_id where tmci.mechanism_id=‘1188’ and ((tmm.check_status = 1 and tmm.merchant_type != 1) or tmm.merchant_id is null)
select count(distinct tmci.company_info_id) ,count( tmm.company_info )from tc_mch_company_info tmci left join tc_mch_merchant tmm on tmm.company_info_id=tmci.company_info_id left join tc_mch_merchant_report tmmr ON tmci. company_info_id = tmmr. company_info_id left join ( select GROUP_CONCAT(tag.name) as tagsName, GROUP_CONCAT(tag.id) as tagsId, tagCompany. company_info_id as companyInfoId from tc_mch_tag_company tagCompany left join tc_mch_tag tag on tagCompany. tag_id = tag.id group by tagCompany. company_info_id ) companyTag on tmci. company_info_id = companyTag.companyInfoId left join tc_mch_agents tma on tma.agent_id=tmm.agent_id where tmci.mechanism_id=‘1188’ and ((tmm. check_status = 1 and tmm.merchant_type != 1) or tmm. merchant_id is null)