gpt4 book ai didi

mysql - 在一张表中分组

转载 作者:行者123 更新时间:2023-11-29 06:27:50 25 4
gpt4 key购买 nike

我有用户列表和访问表。我想要一个已查看过个人资料的用户列表:

visits table
╔═════════════════╗
║ vistor visited ║
╠═════════════════╣
║'26000', '26023' ║
║'26000', '26023' ║
║'26000', '26023' ║
║'26000', '26023' ║
║'26000', '26023' ║
║'26000', '26023' ║
║'26000', '26023 ║
║'26001', '26023' ║
║'26001', '26023' ║
║'26002', '26023' ║
║'26005', '26000 ║
║'26005', '26000' ║
║'26004', '26000' ║
╚═════════════════╝

我想要每个用户的观看次数

╔═════════════════╗
║ visited count ║
╠═════════════════╣
║'26023', 3 ║
║'26000', 2 ║
╚═════════════════╝

最佳答案

您似乎想要count(distinct):

select visited, count(distinct visitor)
from t
group by visited;

关于mysql - 在一张表中分组,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/58465119/

25 4 0
Copyright 2021 - 2024 cfsdn All Rights Reserved 蜀ICP备2022000587号
广告合作:1813099741@qq.com 6ren.com