34,590
社区成员
发帖
与我相关
我的任务
分享
declare @t table(name varchar(5),date datetime, rel varchar(10))
insert into @t select 'A','2007-1-1','AA'
insert into @t select 'A','2007-1-2','AA'
insert into @t select 'A','2007-1-2','AA'
insert into @t select 'A','2007-1-3','AA'
insert into @t select 'B','2007-1-1','bb'
insert into @t select 'B','2007-1-1','bb'
insert into @t select 'B','2007-1-2','bb'
insert into @t select 'c','2007-1-1','cc'
insert into @t select 'c','2007-1-1','cc'
select name,count(distinct date) from @t group by name