sql 中group by 之后count用法

2024-11-11 10:53:49
推荐回答(1个)
回答1:

看样子像是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