gpt4 book ai didi

MySQL查询以获取唯一值的计数?

转载 作者:IT老高 更新时间:2023-10-29 00:14:22 35 4
gpt4 key购买 nike

命中表:

hid | lid | IP
1 | 1 | 123.123.123.123
2 | 1 | 123.123.123.123
3 | 2 | 123.123.123.123
4 | 2 | 123.123.123.123
5 | 2 | 123.123.123.124
6 | 2 | 123.123.123.124
7 | 3 | 123.123.123.124
8 | 3 | 123.123.123.124
9 | 3 | 123.123.123.124

如您所见,以下是各种盖子的独特命中:

lid 1: 1 unique hit
lid 2: 2 unique hits
lid 3: 1 unique hit

所以基本上,我需要一个将返回以下内容的查询:

lid | uhits |
1 | 1 |
2 | 2 |
3 | 1 |

有人知道怎么弄吗?

最佳答案

Select lid, count(distinct IP) as uhits
from hits
group by lid

关于MySQL查询以获取唯一值的计数?,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/2832305/

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