create account

STEEM SQL 系列之 如何获取最近7天 CN 区用户发贴量,点赞数和估计收益值 SteemSQL Tutorial: How to Get Authors Order By Potential Payout in Last 7 days? by justyy

View this thread on: hive.blogpeakd.comecency.com
· @justyy · (edited)
$31.65
STEEM SQL 系列之 如何获取最近7天 CN 区用户发贴量,点赞数和估计收益值 SteemSQL Tutorial: How to Get Authors Order By Potential Payout in Last 7 days?
I will start the tutorial series of getting STEEM data via sql.steemdata.com. The tool we are using here is   [LinqPad](https://www.linqpad.net/)  and today, I am going to show you how to get the list of authors in the last 7 days who have published posts on the first tag 'cn'. The results are sorted by total pending payout.

You can also contact me @justyy  if you want to learn a particular SQL but you don't know how to write it, which then may be included in the next posts.

SQL很简单,我认为是 Sexy Query (查询) Language 语言。这个语言很强大,主要用于操作数据库,现在比较流行的有 MSSQL, [MYSQL](https://justyy.com/archives/5043), SQL SERVER, ORACLE 等。

我们用 [LinqPad](https://www.linqpad.net/) 来查询 steemsql.com。这个系列每次会讲一个语句,如果你觉得你想知道,但是不清楚怎么写的,很欢迎告诉我,我将会整理到下一系列。

# 基础准备工作
下载 [LinqPad](https://www.linqpad.net/) (免费版就够用了)。然后新建数据库连接:数据库地址是`sql.steemsql.com` 用户名是 `steemit` 密码是 `steemit`

这里不重复贴图了,详细可以看 @joythewanderer 的帖子关于如何[添加链接](https://steemit.com/steemit/@joythewanderer/sql-for-dummies-1-configure-linqpad-with-steemsql-database-sql)。

![](https://steemitimages.com/DQmYNKAEBavXYDjR7G9iRGJ6ADtXJU7cNwkJ7XSPeG3zbmu/image.png)

# 获取最近7天 CN 区用户发贴量,点赞数和估计收益值 
新建 SQL 查询语句,输入以下:

```
select top 30 
   author, 
   count(author) as cnt, 
   sum(net_votes) as votes, 
   sum(pending_payout_value) as pending_payout_value 
from 
   Comments 
where 
   title<>'' and 
   dirty='False' and 
   category='cn' and 
   parent_author=''  and datediff(hour, created, GETDATE()) between 0 and 7*24 
group by 
   author 
order by 
  pending_payout_value desc
```

Run the SQL to fetch the top 30 authors, using the LinqPad:
显示结果如下:
![](https://steemitimages.com/DQmb3UXnfAMuTM3w9MnAsnni6cu5Lyohk9hoaQryi27Tofc/image.png)

- 这里 `top 30` 就是取前30个结果
- 按 估计收益值从大到小排序:`order by   pending_payout_value desc`
- 限制 CN 社区: ` category='cn' `
- 好的帖子 e.g 不被踩过的帖子:`dirty='False`
- 是主贴(并不是评论)`parent_author='' ` 和 `title <> ''` 标题不为空,两个条件一结合比较严格。我发现像 @minnowbooster 的回复也是有带标题的。
- 时间是过去7天:` datediff(hour, created, GETDATE()) between 0 and 7*24 `
- 把所有按 `author` 的帖子分组,取数量,点赞数 还有潜在收益。

前三甲: @oflyhigh   @rivalhw  @tumutanzi,大腿还有地么?

另:我会今晚把这个排名加到我的[ 每日榜单里](https://steemit.com/ranking/@justyy/2017-08-26-cn),多提提意见。我想弄一个 [有心的机器人](https://steemit.com/cn/@oflyhigh/28gqnr)  (至少 half human, half bot),让你们都爱上我,哈哈。

更新:[今日榜单已经加上](https://steemit.com/ranking/@justyy/2017-08-26-cn)。

https://justyy.com/wp-content/uploads/2017/07/justyy-steemit.png

Originally published at https://steemit.com Thank you for reading my post, feel free to Follow, Upvote, Reply, ReSteem (repost) @justyy which motivates me to create more quality posts.

原创 https://Steemit.com 首发。感谢阅读,如有可能,欢迎Follow, Upvote, Reply, ReSteem (repost) @justyy 激励我创作更多更好的内容。

// Later, it will be reposted to my blogs: [justyy.com](https://justyy.com), [helloacm.com](https://helloacm.com) and [codingforspeed.com](https://codingforspeed.com)  稍后同步到我的[中文博客](https://justyy.com)和英文[计算机](https://helloacm.com)[博客](https://codingforspeed.com)。
- [STEEM SQL 系列之 如何获取最近7天 CN 区用户发贴量,点赞数和估计收益值](https://justyy.com/archives/5198)
- [SteemSQL Tutorial: How to Get Authors Order By Potential Payout in Last 7 days?](https://helloacm.com/steemsql-tutorial-how-to-get-authors-order-by-potential-payout-in-last-7-days/)

# 近期热贴
- [LOGO 海龟作画 系列二 之定义个过程来 say Hello, World](https://steemit.com/cn/@justyy/logo-say-hello-world-logo-turtle-graphics-series-2-define-procedure-and-say-hello-world)
- [写在2017年七夕: 爱情亲情,那些美好的回忆(就是这么任性的撒狗粮)](https://steemit.com/cn/@justyy/photography-of-our-love-2017)
- [LOGO 海龟作画 系列 一 之 给孩子最好的编程启蒙语言](https://steemit.com/cn/@justyy/logo-logo-turtle-graphics-series-1-best-introductory-programming-for-kids)
- [通过脑残语言来保护你的STEEM钱包密码](https://steemit.com/cn/@justyy/steem-use-brainfuck-to-protect-your-steem-wallet-password-s)
- [不会写程序也能自动点赞 - 通过 SteemVoter 添加点赞规则](https://steemit.com/cn/@justyy/steemvoter)
- [你好秋天,英国8月份的到Hitchin看薰衣草](https://steemit.com/cn/@justyy/8-hitchin)
- [Fen Drayton村每年举行1万米比赛](https://steemit.com/cn/@justyy/fen-drayton-1)
- [碎碎念第365天](https://steemit.com/cn/@justyy/365-the-day-365-at-steemit)

# Recent Popular Posts 
- [Logo Turtle Graphics - Series 2 - Define Procedure and Say Hello, World](https://steemit.com/cn/@justyy/logo-say-hello-world-logo-turtle-graphics-series-2-define-procedure-and-say-hello-world)
- [Photography of Our Love](https://steemit.com/cn/@justyy/photography-of-our-love-2017)
- [Logo Turtle Graphics - Series 1 - Best Introductory Programming for Kids](https://steemit.com/cn/@justyy/logo-logo-turtle-graphics-series-1-best-introductory-programming-for-kids)
- [Use BrainFuck to Protect Your Steem Wallet Password(s)](https://steemit.com/cn/@justyy/steem-use-brainfuck-to-protect-your-steem-wallet-password-s)
- [Hello Autumn! Hello Lavender](https://steemit.com/cn/@justyy/8-hitchin)
- [The Day 365 at SteemIt](https://steemit.com/cn/@justyy/365-the-day-365-at-steemit)
- [The profiler told me I wrote some useless code](https://steemit.com/cn/@justyy/the-profiler-told-me-i-wrote-some-useless-code-an-example-of-defensive-programming)

https://justyy.com/gif/steemit.gif
Tags: #cn #cn-programming #steem-dev #steem-sql #steemit
👍  , , , , , , , , , , , , , , , , , , , , , , , , , , , , , , , , , , , , , , , , , , , , , , , , , , , , , , , , , , , , , , , , and 15 others
properties (23)
authorjustyy
permlinksteem-sql-7-cn
categorycn
json_metadata{"tags":["cn","cn-programming","steem-dev","steem-sql","steemit"],"users":["justyy","joythewanderer","minnowbooster","oflyhigh","rivalhw","tumutanzi"],"image":["https://steemitimages.com/DQmYNKAEBavXYDjR7G9iRGJ6ADtXJU7cNwkJ7XSPeG3zbmu/image.png","https://steemitimages.com/DQmb3UXnfAMuTM3w9MnAsnni6cu5Lyohk9hoaQryi27Tofc/image.png","https://justyy.com/wp-content/uploads/2017/07/justyy-steemit.png","https://justyy.com/gif/steemit.gif"],"links":["https://www.linqpad.net/","https://justyy.com/archives/5043","https://steemit.com/steemit/@joythewanderer/sql-for-dummies-1-configure-linqpad-with-steemsql-database-sql","https://steemit.com/ranking/@justyy/2017-08-26-cn","https://steemit.com/cn/@oflyhigh/28gqnr","https://steemit.com","https://Steemit.com","https://justyy.com","https://helloacm.com","https://codingforspeed.com","https://justyy.com/archives/5198","https://helloacm.com/steemsql-tutorial-how-to-get-authors-order-by-potential-payout-in-last-7-days/","https://steemit.com/cn/@justyy/logo-say-hello-world-logo-turtle-graphics-series-2-define-procedure-and-say-hello-world","https://steemit.com/cn/@justyy/photography-of-our-love-2017","https://steemit.com/cn/@justyy/logo-logo-turtle-graphics-series-1-best-introductory-programming-for-kids","https://steemit.com/cn/@justyy/steem-use-brainfuck-to-protect-your-steem-wallet-password-s","https://steemit.com/cn/@justyy/steemvoter","https://steemit.com/cn/@justyy/8-hitchin","https://steemit.com/cn/@justyy/fen-drayton-1","https://steemit.com/cn/@justyy/365-the-day-365-at-steemit","https://steemit.com/cn/@justyy/the-profiler-told-me-i-wrote-some-useless-code-an-example-of-defensive-programming"],"app":"steemit/0.1","format":"markdown"}
created2017-08-26 16:35:06
last_update2017-09-02 09:18:24
depth0
children13
last_payout2017-09-02 16:35:06
cashout_time1969-12-31 23:59:59
total_payout_value24.490 HBD
curator_payout_value7.163 HBD
pending_payout_value0.000 HBD
promoted0.000 HBD
body_length5,090
author_reputation280,616,224,641,976
root_title"STEEM SQL 系列之 如何获取最近7天 CN 区用户发贴量,点赞数和估计收益值 SteemSQL Tutorial: How to Get Authors Order By Potential Payout in Last 7 days?"
beneficiaries[]
max_accepted_payout1,000,000.000 HBD
percent_hbd10,000
post_id12,948,792
net_rshares7,836,789,582,960
author_curate_reward""
vote details (79)
@anadikc ·
Your posts are very informative but its sad i have to wait once in a while to get them in english. Most of the time i just copy your headlines to google translate to see what it means. Finally after 10 days , I am reading one of your blogs again.

// 稍后同步到我的中文博客和英文计算
机博客。
  Shāo hòu tóngbù dào wǒ de zhōngwén bókè hé yīngwén jì suàn
jī bókè.

// later sync to my Chinese blog and English calculations
Machine blog.

I guess you know what i mean now..Thanks for the language conversions you are doing. Regards,
Anadi
properties (22)
authoranadikc
permlinkre-justyy-steem-sql-7-cn-20170827t102020889z
categorycn
json_metadata{"tags":["cn"],"app":"steemit/0.1"}
created2017-08-27 10:20:21
last_update2017-08-27 10:20:21
depth1
children2
last_payout2017-09-03 10:20:21
cashout_time1969-12-31 23:59:59
total_payout_value0.000 HBD
curator_payout_value0.000 HBD
pending_payout_value0.000 HBD
promoted0.000 HBD
body_length516
author_reputation269,648,682,949
root_title"STEEM SQL 系列之 如何获取最近7天 CN 区用户发贴量,点赞数和估计收益值 SteemSQL Tutorial: How to Get Authors Order By Potential Payout in Last 7 days?"
beneficiaries[]
max_accepted_payout1,000,000.000 HBD
percent_hbd10,000
post_id13,012,781
net_rshares0
@justyy ·
Thanks for your suggestions. I'll try my best to make my posts bilingual..
👍  
properties (23)
authorjustyy
permlinkre-anadikc-re-justyy-steem-sql-7-cn-20170827t102224816z
categorycn
json_metadata{"tags":["cn"],"app":"steemit/0.1"}
created2017-08-27 10:22:24
last_update2017-08-27 10:22:24
depth2
children1
last_payout2017-09-03 10:22:24
cashout_time1969-12-31 23:59:59
total_payout_value0.000 HBD
curator_payout_value0.000 HBD
pending_payout_value0.000 HBD
promoted0.000 HBD
body_length74
author_reputation280,616,224,641,976
root_title"STEEM SQL 系列之 如何获取最近7天 CN 区用户发贴量,点赞数和估计收益值 SteemSQL Tutorial: How to Get Authors Order By Potential Payout in Last 7 days?"
beneficiaries[]
max_accepted_payout1,000,000.000 HBD
percent_hbd10,000
post_id13,012,903
net_rshares1,064,096,018
author_curate_reward""
vote details (1)
@anadikc ·
Thank you.
properties (22)
authoranadikc
permlinkre-justyy-re-anadikc-re-justyy-steem-sql-7-cn-20170827t103733800z
categorycn
json_metadata{"tags":["cn"],"app":"steemit/0.1"}
created2017-08-27 10:37:33
last_update2017-08-27 10:37:33
depth3
children0
last_payout2017-09-03 10:37:33
cashout_time1969-12-31 23:59:59
total_payout_value0.000 HBD
curator_payout_value0.000 HBD
pending_payout_value0.000 HBD
promoted0.000 HBD
body_length10
author_reputation269,648,682,949
root_title"STEEM SQL 系列之 如何获取最近7天 CN 区用户发贴量,点赞数和估计收益值 SteemSQL Tutorial: How to Get Authors Order By Potential Payout in Last 7 days?"
beneficiaries[]
max_accepted_payout1,000,000.000 HBD
percent_hbd10,000
post_id13,013,764
net_rshares0
@cornholio ·
I am Cornholio! You will co-operate with my bunghole!
properties (22)
authorcornholio
permlinkre-justyy-steem-sql-7-cn-20170902t094614250z
categorycn
json_metadata{"tags":["cn"],"app":"meep_bot/0.0.1"}
created2017-09-02 09:46:15
last_update2017-09-02 09:46:15
depth1
children0
last_payout2017-09-09 09:46:15
cashout_time1969-12-31 23:59:59
total_payout_value0.000 HBD
curator_payout_value0.000 HBD
pending_payout_value0.000 HBD
promoted0.000 HBD
body_length54
author_reputation606,749,206,056
root_title"STEEM SQL 系列之 如何获取最近7天 CN 区用户发贴量,点赞数和估计收益值 SteemSQL Tutorial: How to Get Authors Order By Potential Payout in Last 7 days?"
beneficiaries[]
max_accepted_payout1,000,000.000 HBD
percent_hbd10,000
post_id13,632,938
net_rshares0
@holl.boll ·
WOW NICE LIKE IT
I am voting for you, you too have voted, so good that we can go ahead with one another.
properties (22)
authorholl.boll
permlinkre-justyy-steem-sql-7-cn-20170827t044517216z
categorycn
json_metadata{"tags":["cn"],"app":"steemit/0.1"}
created2017-08-27 04:45:15
last_update2017-08-27 04:45:15
depth1
children0
last_payout2017-09-03 04:45:15
cashout_time1969-12-31 23:59:59
total_payout_value0.000 HBD
curator_payout_value0.000 HBD
pending_payout_value0.000 HBD
promoted0.000 HBD
body_length104
author_reputation-30,357,862,109
root_title"STEEM SQL 系列之 如何获取最近7天 CN 区用户发贴量,点赞数和估计收益值 SteemSQL Tutorial: How to Get Authors Order By Potential Payout in Last 7 days?"
beneficiaries[]
max_accepted_payout1,000,000.000 HBD
percent_hbd10,000
post_id12,993,230
net_rshares0
@tvb ·
你也开始玩简单的了~~
properties (22)
authortvb
permlinkre-justyy-steem-sql-7-cn-20170828t104053619z
categorycn
json_metadata{"tags":["cn"],"app":"steemit/0.1"}
created2017-08-28 10:40:57
last_update2017-08-28 10:40:57
depth1
children7
last_payout2017-09-04 10:40:57
cashout_time1969-12-31 23:59:59
total_payout_value0.000 HBD
curator_payout_value0.000 HBD
pending_payout_value0.000 HBD
promoted0.000 HBD
body_length11
author_reputation35,098,102,223,749
root_title"STEEM SQL 系列之 如何获取最近7天 CN 区用户发贴量,点赞数和估计收益值 SteemSQL Tutorial: How to Get Authors Order By Potential Payout in Last 7 days?"
beneficiaries[]
max_accepted_payout1,000,000.000 HBD
percent_hbd10,000
post_id13,110,381
net_rshares0
@justyy · (edited)
不简单没有人赞啊  可以看看我的每日排行 :

- [Daily Top 30 Authors in [CN] 每日cn社区之【请再给我一次机会】+【过去7天收益排行榜】 (2017-08-28)](https://steemit.com/cn/@justyy/daily-top-30-authors-in-cn-cn7-2017-08-28)
- [Daily Top 30 Authors in [CN] 每日cn社区之【请再给我一次机会】+【过去7天收益排行榜】 (2017-08-27)](https://steemit.com/stats/@justyy/daily-top-30-authors-in-cn-cn7-2017-08-27)
👍  
properties (23)
authorjustyy
permlinkre-tvb-re-justyy-steem-sql-7-cn-20170828t104707739z
categorycn
json_metadata{"tags":["cn"],"links":["https://steemit.com/cn/@justyy/daily-top-30-authors-in-cn-cn7-2017-08-28","https://steemit.com/stats/@justyy/daily-top-30-authors-in-cn-cn7-2017-08-27"],"app":"steemit/0.1"}
created2017-08-28 10:47:09
last_update2017-08-28 13:54:36
depth2
children6
last_payout2017-09-04 10:47:09
cashout_time1969-12-31 23:59:59
total_payout_value0.000 HBD
curator_payout_value0.000 HBD
pending_payout_value0.000 HBD
promoted0.000 HBD
body_length326
author_reputation280,616,224,641,976
root_title"STEEM SQL 系列之 如何获取最近7天 CN 区用户发贴量,点赞数和估计收益值 SteemSQL Tutorial: How to Get Authors Order By Potential Payout in Last 7 days?"
beneficiaries[]
max_accepted_payout1,000,000.000 HBD
percent_hbd10,000
post_id13,110,857
net_rshares2,324,050,007
author_curate_reward""
vote details (1)
@tvb ·
我觉得简单哈哈哈,我今天工作用到了api接口,就是在前端用ajax,刚好前几天你提过我当时就试了一下,今天直接用上了。你真是我的明灯哈哈哈
properties (22)
authortvb
permlinkre-justyy-re-tvb-re-justyy-steem-sql-7-cn-20170828t135258732z
categorycn
json_metadata{"tags":["cn"],"app":"steemit/0.1"}
created2017-08-28 13:53:03
last_update2017-08-28 13:53:03
depth3
children2
last_payout2017-09-04 13:53:03
cashout_time1969-12-31 23:59:59
total_payout_value0.000 HBD
curator_payout_value0.000 HBD
pending_payout_value0.000 HBD
promoted0.000 HBD
body_length69
author_reputation35,098,102,223,749
root_title"STEEM SQL 系列之 如何获取最近7天 CN 区用户发贴量,点赞数和估计收益值 SteemSQL Tutorial: How to Get Authors Order By Potential Payout in Last 7 days?"
beneficiaries[]
max_accepted_payout1,000,000.000 HBD
percent_hbd10,000
post_id13,125,409
net_rshares0
@tvb ·
哈哈再给你几次机会了,我都看了呢,因为没有我,我就默默的点了个赞然后离去了哈哈哈
properties (22)
authortvb
permlinkre-justyy-re-tvb-re-justyy-steem-sql-7-cn-20170828t135642250z
categorycn
json_metadata{"tags":["cn"],"app":"steemit/0.1"}
created2017-08-28 13:56:45
last_update2017-08-28 13:56:45
depth3
children2
last_payout2017-09-04 13:56:45
cashout_time1969-12-31 23:59:59
total_payout_value0.000 HBD
curator_payout_value0.000 HBD
pending_payout_value0.000 HBD
promoted0.000 HBD
body_length40
author_reputation35,098,102,223,749
root_title"STEEM SQL 系列之 如何获取最近7天 CN 区用户发贴量,点赞数和估计收益值 SteemSQL Tutorial: How to Get Authors Order By Potential Payout in Last 7 days?"
beneficiaries[]
max_accepted_payout1,000,000.000 HBD
percent_hbd10,000
post_id13,125,759
net_rshares0