mmysql根据某个字段切割并分组,在统计

mysql根据某个字段切割并分组,再统计

1.数据库表
在这里插入图片描述

substring_index( substring_index( a.desired_position_code, ',', b.help_topic_id + 1 ), ',',- 1 ) code 
FROM
	tb_biz_resume a
	JOIN mysql.help_topic b ON b.help_topic_id < ( length( a.desired_position_code ) - length( REPLACE ( a.desired_position_code, ',', '' ) ) + 1 ) 
 where 1=1
    and   a.create_time >= CONCAT('2020-10-12',' 00:00:00')
    and a.create_time <= CONCAT('2020-10-12',' 23:59:59')

在这里插入图片描述
然后在分组统计


select question.type_code,
chapter.code,
COUNT(DISTINCT question.id) counts
FROM
(
SELECT DISTINCT
	substring_index( substring_index( a.desired_position_code, ',', b.help_topic_id + 1 ), ',',- 1 ) code 
FROM
	tb_biz_resume a
	JOIN mysql.help_topic b ON b.help_topic_id < ( length( a.desired_position_code ) - length( REPLACE ( a.desired_position_code, ',', '' ) ) + 1 ) 
 where 1=1
    and   a.create_time >= CONCAT('2020-10-12',' 00:00:00')
    and a.create_time <= CONCAT('2020-10-12',' 23:59:59')
)as chapter,

(select desired_position_code,id,region,type_code
from tb_biz_resume
 where 1=1
    and   create_time >= CONCAT('2020-10-12',' 00:00:00')
    and create_time <= CONCAT('2020-10-12',' 23:59:59')
) as question 


 where 1=1
and question.desired_position_code like concat('%',chapter.code,'%')
group by question.region,chapter.code ;

在这里插入图片描述

评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包
实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

1.余额是钱包充值的虚拟货币,按照1:1的比例进行支付金额的抵扣。
2.余额无法直接购买下载,可以购买VIP、付费专栏及课程。

余额充值