1

我想知道特定用户在同一天进行活动的频率

SELECT COUNT(*) FROM Activity
GROUP BY entity_uid, date

这将返回一长串计数:即

1
1
2
1

然后我想对这个查询的结果进行分组,告诉我每个数字在结果集中出现的频率,像这样

#    Count(*)
1    3
2    1

这是我所拥有的,但它不起作用

Select x = (
            SELECT COUNT(*) FROM Activity
            GROUP BY entity_uid, date
           ),
       Count(*)
GROUP BY x

如何在变量中选择子查询的结果?

4

2 回答 2

2

试试下面

select daily_user_count, count(*) from (
SELECT COUNT(*) as daily_user_count FROM Activity
GROUP BY entity_uid, date
) Z
group by daily_user_count
于 2013-07-03T14:01:43.663 回答
1

尝试

SELECT Frequency, COUNT(*) [Count]
FROM (
    SELECT COUNT(*) Frequency 
    FROM Activity
    GROUP BY entity_uid, date
) t
GROUP BY Frequency
于 2013-07-03T14:01:54.820 回答