Access 中不同值的运行计数 [英] Running count of distinct values in Access

查看:27
本文介绍了Access 中不同值的运行计数的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我在 MS Access 数据库中存储了如下数据:

I have data stored as below in an MS Access database:

Date         User
20090101     1001
20090101     1002
20090102     1001
20090103     1001
20090103     1003

我正在尝试创建一个查询,以显示唯一用户的每日运行计数.例如:

I'm attempting to create a query which shows the daily running count of unique users. For example:

Date        Daily Count   Unique User Running Count
20090101    2             2
20090102    1             2
20090103    2             3

实现这一目标的最佳方法是什么?

What's the best way to achieve this?

推荐答案

在大多数 SQL 实现中,您可以使用聚合函数 count(distinct user) 进行选择.但是 Access 不支持该构造.我认为你能做的最好的事情是在子查询中选择不同的值并计算它们.

In most SQL implementations you could select using the aggregate function count(distinct user). But Access doesn't support that construct. I think the best you could do is to select the distinct values in a subquery and count them.

我打算写一个查询,但是这个link 似乎做得很好.

I was going to write a query but this link seems to do a good job.

HTH汤姆

这篇关于Access 中不同值的运行计数的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆