--下面是测试结果
create table #mytable
(
mytype varchar(10),
myint int
)
insert into #mytable values('a',100)
insert into #mytable values('b',800)
insert into #mytable values('ab',100)
select
mytype,
(
select sum(myint) from #mytable t2
where t2.mytype like '%'+t1.mytype+'%'
) as myintSum
from #mytable t1
where len(mytype)=1
drop table #mytable