sql 一列拼接成一行,再分割成列
原始数据,需要拼接成一行
select * from (select d.*,(SELECT count ([Keyword])FROM [DragonGuoShi].[dbo].[ArticleInfo]where Keyword like'%'+d.Keyword+'%' and [ArticleCreateDate]>'2018-06-10') as Num from (select distinct(Keyword) from( select SUBSTRING( Keyword,number,CHARINDEX(',',Keyword+',',number)-number) as Keyword from( SELECT stuff((SELECT ','+[Keyword] from (SELECT [Keyword]FROM [DragonGuoShi].[dbo].[ArticleInfo]where Keyword!='' and [ArticleCreateDate]>'2018-06-10')a for xml path('')),1,1,'') as Keyword)b ,master..spt_values where
number >=1 and number<=len(Keyword)
and type='p'
and substring(','+Keyword,number,1)=',') c ) d ) e where Num>20 order by Num desc
结果
无人机技术交流QQ群:951349285,mavlink,missionplanner,qgroundcontrol,PX4,ArduPilot。
JAVA&NET技术,跳槽,软考交流QQ群:456257217,有问题的可以在群里面提问交流。