SteemSQL 系列教程之 – 你的哪些好友已经好久没玩STEEM了?


假设你想知道你关注的哪些好友很久没玩STEEM了, 你可以通过 @arcange 的 STEEMSQL 来进行查询. 我们可以简单的定义7天内如果用户没有发表评论或者文章就算没玩(因为可以通过机器人自动点赞)

1
2
3
4
5
6
7
8
9
10
select author, datediff(day, T.last, GetUTCDate()) 
from 
(
    select author, max(created) "last" 
    from Comments 
    where author in ('followingid1', 'followingid2' ...) 
    group by author
) T 
where 
    datediff(day, T.last, GetUTCDate()) > 7
select author, datediff(day, T.last, GetUTCDate()) 
from 
(
    select author, max(created) "last" 
    from Comments 
    where author in ('followingid1', 'followingid2' ...) 
    group by author
) T 
where 
    datediff(day, T.last, GetUTCDate()) > 7

嵌套的SQL用于按用户排序并返回最近一次活动时间 last. 主SQL则把这时间再一次过滤, 去掉7天内有活动的用户: datediff(day, T.last, GetUTCDate()) > 7

我们可以把时间天数间隔保存在嵌套的SQL里当成一字段, 我们还可以从视图 Followers 中取得关注的列表.

1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
select author, T.days
from 
(
    select author, max(created) "last", datediff(day, max(created), GetUTCDate()) "days"
    from Comments 
    where author in (
        select 
            following
        from
            followers
        where
            follower = 'justyy'     
    ) 
    group by author
) T 
where 
    T.days > 7
order by
    T.days desc
select author, T.days
from 
(
    select author, max(created) "last", datediff(day, max(created), GetUTCDate()) "days"
    from Comments 
    where author in (
        select 
            following
        from
            followers
        where
            follower = 'justyy'     
    ) 
    group by author
) T 
where 
    T.days > 7
order by
    T.days desc

上面的SQL就返回了我关注的这用户中已经不玩STEEM的, 你也试试看吧?

STEEM SQL 系列教程

英文: SteemSQL Tutorial – Finding Inactive Steemians that You Follow

GD Star Rating
loading...
本文一共 410 个汉字, 你数一下对不对.
SteemSQL 系列教程之 – 你的哪些好友已经好久没玩STEEM了?. (AMP 移动加速版本)
上一篇: [答案] 数学 × 程式编写比赛 (第八回) - 4位数的电子显示器
下一篇: 说说计算机证书

扫描二维码,分享本文到微信朋友圈
dfc936e52213f0720f5d8923043fd167 SteemSQL 系列教程之 - 你的哪些好友已经好久没玩STEEM了? I.T. SteemIt 数据库

评论