-- 可以拆分为多条数据
SELECT distinct REGEXP_SUBSTR(t.cym, '[^、]+', 1, level) cym, t.* from person_info t connect by level <= regexp_count(t.cym, '、') + 1;
-- 人员统计
select cym, count(1) from (SELECT distinct REGEXP_SUBSTR(t.cym, '[^、]+', 1, level) cym, t.ryxxbz, t.xm from person_info t connect by level <= regexp_count(t.cym, '、') + 1) group by cym;
-- 人员统计
select
SUM( CASE WHEN cym = '重点' THEN 1 ELSE 0 END), --男性人口
SUM( CASE WHEN cym <> '重点' THEN 1 ELSE 0 END) --女性人口
from (SELECT distinct REGEXP_SUBSTR(t.cym, '[^、]+', 1, level) cym, t.ryxxbz, t.xm from person_info t connect by level <= regexp_count(t.cym, '、') + 1) group by cym;
select
SUM( CASE WHEN cym = '重点' THEN 1 ELSE 0 END), --男性人口
SUM( CASE WHEN cym <> '重点' THEN 1 ELSE 0 END) --女性人口
from (SELECT distinct REGEXP_SUBSTR(t.cym, '[^、]+', 1, level) cym, t.ryxxbz, t.xm from person_info t connect by level <= regexp_count(t.cym, '、') + 1) group by cym;
网友评论