小赖子的英国生活和资讯

SteemSQL 教程 – 如何获取史上赚最多金的作者?

阅读 桌面完整版

@nationalpark 兄在过去几天发了好几篇 关于史上最多金的分析. 这篇我将介绍这是如何实现的, 这样的话, 你也可以自己分析这些数据了.

我们都知道在 Comments 表里存放的帖子数据, 这就包括了收益. 我们只需要按 作者来分类 (group by author) 然后累计
total_payout_value (过去已经结算的帖子) 和 total_pending_payout(7天内的帖子) 即可.

1
2
3
4
5
6
7
8
select top 100
    author, sum(total_payout_value) + sum(total_pending_payout_value)
from
    comments (NOLOCK)
group by
    author
order by
    sum(total_payout_value) + sum(total_pending_payout_value) desc
select top 100
    author, sum(total_payout_value) + sum(total_pending_payout_value)
from
    comments (NOLOCK)
group by
    author
order by
    sum(total_payout_value) + sum(total_pending_payout_value) desc

本来想写一个在线工具的, 无奈这个SQL执行效率太慢, 因为需要遍例大量的文章才能统计得出结果.

steemsql-top-authors

这里的收益包括25%的点赞收益, 所以大概你需要 X 0.75才能得到收益情况. 比如, 我改了一下, 只显示我的:

1
2
3
4
5
6
7
8
select 
    author, sum(total_payout_value) + sum(total_pending_payout_value)
from
    comments (NOLOCK)
group by
    author
having
    author = 'justyy'
select 
    author, sum(total_payout_value) + sum(total_pending_payout_value)
from
    comments (NOLOCK)
group by
    author
having
    author = 'justyy'

得到结果:

steemsql-authors-payout

也就是说, 我大概得到比 11152.3 * 0.75 = 8364 SBD稍微多一点点的收入.

回到第一个语句, 我们可以添加一个时间限制, 比如显示过去30天的收排名:

1
2
where
    datediff(day, created, GetUTCDate()) between 0 and 30
where
    datediff(day, created, GetUTCDate()) between 0 and 30

是不是很简单? 继续写吧, 兄弟姐妹们!

英文: SteemSQL Tutorial: How to Get the Most Payout Authors in History?

STEEM SQL 系列教程

强烈推荐

微信公众号: 小赖子的英国生活和资讯 JustYYUK

阅读 桌面完整版
Exit mobile version