【发布时间】:2018-07-23 07:13:51
【问题描述】:
【问题讨论】:
【问题讨论】:
你好像有很多不同名字的同一所大学,比如这些
JIIT
"JIIT
jiit
尝试对它们进行规范化(转换为大写并删除'"'),这样group by之后的JIIT将是相同的:
select case when college = 'BSA' then 'BSA College of Technology'
--add other cases
else --rule for others
trim(upper(regexp_replace(college,'"','')))
end as college
,COUNT(*) as cnt
from students
group by
case when college = 'BSA' then 'BSA College of Technology'
--add other cases
else --rule for others
trim(upper(regexp_replace(college,'"','')))
end --the same sentence should be in group by, or use subquery instead
;
应用case 将MJP ROHILKHAND 和M J P ROHILKHAND 等更复杂的字符串转换为相同的字符串。
发生这种情况是因为数据库未规范化,并且 College 列的输入不受 College 维度的限制。
【讨论】:
case college when 'One form' then 'another form' when 'this' then 'that' ... else college end as college,结合两种解决方案