34,590
社区成员
发帖
与我相关
我的任务
分享
with tb(keyword) as(
select '苹果,ipad,google' union all
select '三国杀,ipad,苹果,qq' union all
select '苹果,三国杀,qq' union all
select 'iphone,三国杀,qq' ),tc as(
select a=substring(keyword,number,CHARINDEX(',',keyword+',',number+1)-number),
b=COUNT(1) from tb,master..spt_values where type='p'
and SUBSTRING(','+keyword,number,1)=','
group by substring(keyword,number,CHARINDEX(',',keyword+',',number+1)-number))
select a=stuff((select ','+a from tc order by b desc for xml path('')),1,1,'')