CREATE TABLE #t(age nvarchar(50) , count nvarchar(50))
insert into #t (age) value('0-20')
insert into #t (age) value('20-30')
insert into #t (age) value('30-40')
update a set count =(select count(age) from ageid where age>=0 and age<=20) from #t a where a.age='0-20'
update a set count =(select count(age) from ageid where age>20 and age<=30)from #t a where a.age='20-30'
update a set count =(select count(age) from ageid where age >30 and age<40)from #t a where a.age='30-40'
select * from #t
这样分开写看的容易点