看样子像是access啊?
access的话:
select t.id,count(t.随访号) as 随访次数 from(select id,随访号 from 表1 group by id,随访号) as t group by t.id
其他数据库的话:
select id,count(distinct 随访号) as 随访次数 from 表1 group by id