关闭

当字段内有逗号分隔时,SQL如何对这些字段值进行分组

243人阅读 评论(0) 收藏 举报
分类:


select  

    b.PRIMARYPOLLUTANT,count(b.PRIMARYPOLLUTANT) as primarypollutantCount
 from  
     (select PRIMARYPOLLUTANT=convert(xml,' <root> <v>'+replace(PRIMARYPOLLUTANT,',',' </v> <v>')+' </v> </root>') from AIR_BASE_DAY_AQI
     where AQI>='100' and TIMEPOINT>='2016-12-11' and TIMEPOINT<'2016-12-13')a
 outer apply
     (select PRIMARYPOLLUTANT=C.v.value('.','nvarchar(100)') from a.PRIMARYPOLLUTANT.nodes('/root/v')C(v))b
  group by b.PRIMARYPOLLUTANT

0
0

查看评论
* 以上用户言论只代表其个人观点,不代表CSDN网站的观点或立场