您好, 欢迎来到 !    登录 | 注册 | | 设为首页 | 收藏本站

MS ACCESS:如何使用访问查询来计算不同的价值?

MS ACCESS:如何使用访问查询来计算不同的价值?

尝试

select ..., count(distinct Training.Tcode) as ..., ...

采取以下sql代码。第一个选择是sql Server如何执行此操作,第二个查询应符合访问权限…

declare @t table (eCode int, tcode int)
insert into @t values(1,1)
insert into @t values(1,1)
insert into @t values(1,2)
insert into @t values(1,3)
insert into @t values(2,2)
insert into @t values(2,3)
insert into @t values(3,1)

select 
    ecode, count(distinct tCode) countof
from
    @t
group by
    ecode

select ecode, count(*)
from
    (select distinct tcode, ecode
    from  @t group by tcode, ecode) t
group by ecode

它返回以下内容

ecode tcode
1       3 (there are 3 distinct tcode for ecode of 1)
2       2 (there are 2 distinct tcode for ecode of 2)
3       1 (there is 1 distinct tcode for ecode of 3)
Access 2022/1/1 18:49:52 有544人围观

撰写回答


你尚未登录,登录后可以

和开发者交流问题的细节

关注并接收问题和回答的更新提醒

参与内容的编辑和改进,让解决方法与时俱进

请先登录

推荐问题


联系我
置顶