计算每个用户的事件数量

发布于 2025-02-05 18:04:30 字数 238 浏览 2 评论 0原文

我的表格与此类似:

ID | event | user | time | note | archived

我需要单个用户去过的事件数量,但是一个用户可以在一个事件中拥有一个以上的记录,因此我只需要对其进行计数。

结果应该像这样:

user | nrofevents

感谢您的任何建议。

i have table similar to this:

ID | event | user | time | note | archived

I need the number of events that individual users have been to, but one user can have more than one record for one event, so I only need to count it once.

The result should look like this:

user | nrofevents

Thank you for any advice.

如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。

扫码二维码加入Web技术交流群

发布评论

需要 登录 才能够评论, 你可以免费 注册 一个本站的账号。

评论(1

以往的大感动 2025-02-12 18:04:30

可能只是您需要的不同的使用吗?

select user, count(distinct event) as nrofevents
from t
group by user;

Possibly it's just the use of distinct you need?

select user, count(distinct event) as nrofevents
from t
group by user;
~没有更多了~
我们使用 Cookies 和其他技术来定制您的体验包括您的登录状态等。通过阅读我们的 隐私政策 了解更多相关信息。 单击 接受 或继续使用网站,即表示您同意使用 Cookies 和您的相关数据。
原文