我有用户玩多个游戏长达6个月的数据。
我有表名:App_Click
列名:- user_id, date (用户单击游戏的日期),
app_name
App_click(每个用户的点击总数)
如果条目存在于用户单击的应用程序上(即播放)
问:我正在寻找唯一的用户,他们每周至少在30天或季刊中玩ABC游戏2次或2次以上
寻找解决方案,如:玩ABC: 100的用户总数(也玩过其他游戏的用户)
只玩ABC的用户总数: 30 (只有只玩ABC的用户)
玩过ABC和其他游戏的用户总数: 70 (使用ABC玩其他游戏的用户)
发布于 2020-07-13 14:42:21
您可以使用两个级别的聚合:
select countif(num_abc > 0) as num_abc_users,
countif(num_abc > 0 and num_other = 0) as num_abc_only,
countif(num_abc > 0 and num_other > 0) as num_abc_plus_other
from (select user_id, countif(app_name = 'ABC') as num_abc, countif(app_name <> 'ABC') then num_other
from t
group by user_id
) t;子查询总结了每个用户。外部则聚合这些结果。
https://stackoverflow.com/questions/62878146
复制相似问题