老人类型逗号隔开多个,类型分类统计数量,分组排序
SELECT
b.customer_type_name AS itemName,
count( customer_type_name ) AS
VALUE
FROM
(
SELECT
customer_information_id,
substring_index( substring_index( a.customer_type_name, ',', b.help_topic_id + 1 ), ',',- 1 ) AS customer_type_name
FROM
kn_customer_information a
JOIN mysql.help_topic b ON b.help_topic_id <![CDATA[<]]> ( length( a.customer_type_name ) - length( REPLACE ( a.customer_type_name, ',', '' ) ) + 1 )
WHERE
a.is_deleted = 0
AND a.audit_status = 2
<if test="deptIds != null and deptIds.size() > 0">
AND a.create_dept in
<foreach collection="deptIds" item="id" open="(" separator="," close=")">
#{id}
</foreach>
</if>
) b
GROUP BY
b.customer_type_name
ORDER BY
count( customer_type_name ) DESC