mysql字符串查找(统计客源)
如客源状态为1:2:3:5:6:9,其中6代表成交状态
如果要统计查询出有6这个状态的客源,可以用函数LOCATE(字符,搜索的字符串)来,
示例:统计每个分组下全部客源数total,成交客源数deal
SELECT count(id) total,`group_id`,`group_name`,`project_name`,`format_name` ,SUM(CASE WHEN LOCATE('6',custom_type) <> 0 THEN 1 END) deal FROM `vf_custom_format` WHERE ( `member_channel_id` = 2 ) AND ( `state` = '1' ) GROUP BY group_id