有人知道如何解决这个问题吗?这是我能做的最好的了,但我不认为它是正确的。
With
(select Count(distinct(follower_account_id) as followers
From pw_social_relation)
Select count(distinct(follower_account_id))/followers
From pw_social_relation
Where count(followee_account_id)>=3
发布于 2018-08-03 05:29:07
类似这样的查询将为您工作。
select ((b.result/a.total)*100) as percentage from
(select count(distinct(follower_account_id)) as total from pw_social_relation) a
,(select count(follower_account_id) as result from pw_social_relation group by follower_account_id having count(*) >= 3) b;
我没有执行这个,但这是一个想法,如果你能解决给定的问题。
发布于 2018-08-03 17:37:19
SELECT follower_account_id,(COUNT(distinct(followee_account_id))/@totalfollowers) * 100 as followersPer From pw_social_relation GROUP BY follower_account_id HAVING Count(distinct(followee_account_id)) >= 3
发布于 2018-08-03 21:06:39
首先计算关注量,然后计算至少三个关注量的账户。
总之,虽然乍一看这看起来是正确的.
select
count(case when following >= 3 then 1 end) / count(*) as percentage
from
(
select follower_account_id, count(*) as following
from pw_social_relation
group by follower_account_id
) counted;
..。我认为我们可以推测,可能有一些账户没有关注任何人。因此,我们必须与某些帐户表中的帐户数进行比较。但从这里开始,您可以很容易地相应地调整查询:-)
https://stackoverflow.com/questions/51662277
复制相似问题