select sum(momey),contry=[独联体]  from t where charindex('%[独联体]%',contry)>0
union
select sum(momey),contry=[东欧]  from t where charindex('%[东欧]%',contry)>0把独联体,和东欧用变量代替。。
期待更好的办法!!

解决方案 »

  1.   

    --示例--测试数据
    create table tb(momey int,contry varchar(20))
    insert tb select 100,'独联体,东欧'
    union all select 200,'独联体,'
    union all select 300,'东欧,'
    go--汇总
    select momey=sum(a.momey),b.contry
    from tb a,(
    select contry='独联体'
    union all select '东欧'
    )b where charindex(','+b.contry+',',','+a.contry+',')>0
    group by b.contry
    go--删除测试
    drop table tb/*--测试结果momey       contry 
    ----------- ------ 
    400         东欧
    300         独联体(所影响的行数为 2 行)
    --*/
      

  2.   

    zjcxc(邹建) ( ) 信誉:445 
    的解答是最好的.要不你选择变量分析字符吧,那太累了哈