SteemSQL Tutorial – Get Most Single Payout Authors


@nationalpark in his post has listed the top authors that publish exactly 1 post and earn the most. This SteemSQL tutorial is going to uncover the magic behind the scene thanks to @arcange ‘s hard work on maintaining SteemSQL.

Let’s say we need to limit to those authors by publishing only 1 post (excluding comments), by using this criteria.

depth = 0

Then, we need to group author and check if the count of the post is one by having count(1) = 1 i.e. we use having on aggregated fields i.e. author

Then, we just need to sort the result in descending order order by max(total_payout_value) desc because it is only 1 post, you can use max, min or sum which does not make any differences.

The final SQL is:

1
2
3
4
5
6
7
8
9
10
11
12
13
select 
    author, 
    max(total_payout_value) "payout"
from
    comments (NOLOCK)       
where
    depth = 0
group by
    author
having
    count(1) = 1
order by
    max(total_payout_value) desc
select 
    author, 
    max(total_payout_value) "payout"
from
    comments (NOLOCK)       
where
    depth = 0
group by
    author
having
    count(1) = 1
order by
    max(total_payout_value) desc

as you can see max(total_payout_value) is repeated twice, and unlike MySQL, we can’t customize this field and use it as a variable e.g. payout, However we can do a nested SQL, and rewrite the above:

1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
select T.author, T.payout 
from (
    select 
        author, 
        max(total_payout_value) "payout", 
        count(1) "count"
    from
        comments (NOLOCK)       
    where
        depth = 0
    group by
        author
) T
where
    T.count = 1
order by
    T.payout desc
select T.author, T.payout 
from (
    select 
        author, 
        max(total_payout_value) "payout", 
        count(1) "count"
    from
        comments (NOLOCK)       
    where
        depth = 0
    group by
        author
) T
where
    T.count = 1
order by
    T.payout desc

Both queries return the same result:

steemsql-authors-payout-one-post SteemSQL Tutorial - Get Most Single Payout Authors database mssql SteemIt

steemsql-authors-payout-one-post

Confirmed with @arcange, the earnings are SBD not USD, so the figures are slightly different than what you read in @nationalpark ‘s post.

STEEM SQL Tutorial

You may also like: SteemSQL 教程 – 一鸣惊人的作者

–EOF (The Ultimate Computing & Technology Blog) —

GD Star Rating
loading...
661 words
Last Post: SteemSQL Tutorial: How to Get the Most Payout Authors in History?
Next Post: Inconsistent behavior of ScriptControl 64-bit to the msscript.ocx

The Permanent URL is: SteemSQL Tutorial – Get Most Single Payout Authors

Leave a Reply