怎样把数据库的行转成列

admin 2019-3-17 131

犹如下格局的表 Company Name       十五味赛尔斗丸 http://www.wei9316.com/ Exchange   Listing Countries         Business Country              BYD                               OTC PK      USA                                CHN BYD                              SZSE           CHN                               CHN BYD                               XTER          GEM                                CHN BYD                              HKSE           HK                                  CHN 怎样样冠心七味胶囊转成一列,前面戴listing countries呢, 剧本以下 (最关头是细体部份)    select CompanyId,
  CountryId_ = stuff((select ','+ CountryId from #Company where CompanyId=t.CompanyId for xml path('')),1,1,'')
 from #Company t
 group by CompanyId

严字当头!许家印颁27条最严“军规”恒大新赛季剑指双冠腾讯网2019-02-25 21:40
编辑:陈伟霆
最新回复 (0)
返回
发新帖