让我们在这里为Stack Exchange Data Explorer收集一些有趣的查询。

每个标签有多少票? (标签徽章需要多长时间?)

SELECT TOP 20 
    TagName,
    COUNT(*) AS UpVotes 
FROM Tags
    INNER JOIN PostTags ON PostTags.TagId = Tags.id
    INNER JOIN Posts ON Posts.ParentId = PostTags.PostId
    INNER JOIN Votes ON Votes.PostId = Posts.Id
WHERE Votes.VoteTypeId=2 
    AND Posts.CommunityOwnedDate IS NULL 
    AND Posts.OwnerUserId = @UserId
GROUP BY TagName 
ORDER BY UpVotes DESC


我的答案接受的百分比有多高? (我做得好吗?)

SELECT 
    (CAST(COUNT(a.Id) AS float) / (SELECT COUNT(*) FROM Posts WHERE OwnerUserId = @UserId AND PostTypeId = 2) * 100) AS AcceptedPercentage
FROM Posts q
    INNER JOIN Posts a ON q.AcceptedAnswerId = a.Id
WHERE a.OwnerUserId = @UserId 
    AND a.PostTypeId = 2


我的评论有几票? (在Pundit之前需要多长时间?)

SELECT 
    COUNT(*) AS CommentCount, 
    Score
FROM Comments
WHERE UserId = @UserId
GROUP BY Score
ORDER BY Score DESC


如果没有上限或CW,我的声誉大约有多高?

SELECT 
    SUM(CASE
        WHEN VoteTypeId = 1 THEN 15 -- Accepted answer.
        WHEN VoteTypeId = 2 AND PostTypeId = 1 THEN 5 -- Upvoted question.
        WHEN VoteTypeId = 2 AND PostTypeId = 2 THEN 10 -- Upvoted answer.
        WHEN VoteTypeId = 3 THEN -2 -- Downvote.
        WHEN VoteTypeId = 9 THEN BountyAmount -- Earned Bounty.
    END) AS UncappedReputation
FROM Votes
    INNER JOIN Posts ON Posts.Id = Votes.PostId
WHERE Posts.OwnerUserId = @UserId

/>
在同一封电子邮件中拥有10个以上帐户的用户(sockpuppets?哦,哦,詹姆斯·布朗死了!)

SELECT 
    u1.EmailHash, 
    COUNT(u1.Id) AS Accounts, 
    (SELECT CAST(u2.Id AS varchar) + ' (' + u2.DisplayName + '), ' FROM Users u2 WHERE u2.EmailHash = u1.EmailHash FOR XML PATH ('')) AS IdsAndNames
FROM Users u1
WHERE u1.EmailHash IS NOT NULL
GROUP BY u1.EmailHash
HAVING COUNT(u1.Id) > 10
ORDER BY Accounts DESC


> 10张赞成票(悲观主义者;-)) (将PostTypeId更改为1以获得平均问题分数)

SELECT TOP 100 
Id as [User Link],
UpVotes,
DownVotes,
(CAST(DownVotes AS float) / (CASE WHEN UpVotes = 0 THEN 1 ELSE CAST(UpVotes AS float) END)) AS DownVoteRatio
FROM Users
WHERE DownVotes > 10
ORDER BY DownVoteRatio DESC


平均答案分数最高(且具有> 100个答案)的用户

SELECT 
    AVG(CAST(Score AS float)) AS AverageAnswerScore
FROM Posts
    INNER JOIN Users ON Users.Id = OwnerUserId
WHERE OwnerUserId = @UserId 
    AND PostTypeId = 2


自我接受率高(并且有> 10个答案)的用户(极端的自学者)

SELECT TOP 100
    Users.Id,
    DisplayName,
    Count(Posts.Id) AS Answers,
    AVG(CAST(Score AS float)) AS AverageAnswerScore
FROM Posts
    INNER JOIN Users ON Users.Id = OwnerUserId
WHERE PostTypeId = 2
GROUP BY Users.Id, DisplayName
HAVING Count(Posts.Id) > 100
ORDER BY AverageAnswerScore DESC


上/下投票率每周的每一天(周末有更多投票失败的风险?)

SELECT TOP 100 
    Users.Id AS [User Link],
    (CAST(COUNT(a.Id) AS float) / CAST((SELECT COUNT(*) FROM Posts p WHERE p.OwnerUserId = Users.Id AND PostTypeId = 1) AS float) * 100) AS SelfAnswerPercentage
FROM Posts q
    INNER JOIN Posts a ON q.AcceptedAnswerId = a.Id
    INNER JOIN Users ON Users.Id = q.OwnerUserId
WHERE q.OwnerUserId = a.OwnerUserId
GROUP BY Users.Id, DisplayName
HAVING COUNT(a.Id) > 10
ORDER BY SelfAnswerPercentage DESC


我活跃了多少天? (返回您至少发布了一个答案的天数,这对于另一个统计数据可能很有用,因为注册日期并不总是代表“用户活动”。)

SELECT 
    DATENAME(WEEKDAY, CreationDate) AS Day, 
    COUNT(*) AS Amount, 
    SUM(CASE WHEN VoteTypeId = 2 THEN 1 ELSE 0 END) AS UpVotes, 
    SUM(CASE WHEN VoteTypeId = 3 THEN 1 ELSE 0 END) AS DownVotes, 
    (CAST(SUM(CASE WHEN VoteTypeId = 2 THEN 1 ELSE 0 END) AS float) / CAST(SUM(CASE WHEN VoteTypeId = 3 THEN 1 ELSE 0 END) AS float)) AS UpVoteDownVoteRatio
FROM Votes
GROUP BY DATENAME(WEEKDAY, CreationDate)


网站上最具争议的帖子

按标签名称搜索堆栈溢出收藏夹

SELECT COUNT(DISTINCT CONVERT(char(10), CreationDate, 111)) AS days
FROM Posts
WHERE OwnerUserId = ##UserId##


评论

我投票结束这个问题是因为没有话题,因为这是一个无序的混乱,与使用Q&A筛选一堆未分类的答案相比,用户使用Data Explorer上的内置搜索功能会更好对。

@animuson糟糕,Data Explorer站点本身没有投票或共享来源过滤。从头开始,通常比找到一个可以满足您需求的现有查询更好。再说一次,也许我没有利用调整功能来到达想要的位置。

来自所有国家/地区的顶级用户:data.stackexchange.com/stackoverflow/query/1250968

@pt:您忘记了我的国家。

@BalusC啊,对不起,我刚刚从Google那里获得了名单。将更新查询:)

#1 楼

有多少用户可以使用X?

                                                     Min        Number of
Privilege                             Site           Reputation Users
------------------------------------- -------------- ---------- ---------
Users in the data dump for this site  ==>                  -1   1,582,958
Ask and answer questions              *All*                 1   1,582,958
Participate in per-site meta          *All*                 5     732,492
Create community-wiki posts           *All*                10     606,857
Remove new user restrictions          *All*                10     606,857
Flag posts                            *All*                15     461,111
Vote up questions and answers         *All*                15     461,111
Talk in chat                          *All*                20     407,868
Comment everywhere                    Stack Overflow       50     237,807
Set a bounty on a question            *All*                75     190,449
Create chat rooms                     *All*               100     163,348
Edit community wiki questions         *All*               100     163,348
Vote down questions and answers       *All*               125     140,377
Reduced advertising                   Most sites          200     105,753
View close votes                      *All*               250      98,544
Retag questions                       *All*               500      62,872
Create gallery chat rooms             *All*              1000      35,762
Established User                      *All*              1000      35,762
Create new tags                       Stack Overflow     1500      24,940
Edit questions and answers            *All*              2000      18,890
Suggest and vote on tag synonyms      *All*              2500      14,990
Cast close and reopen votes           *All*              3000      12,424
Approve or reject tag wiki edits      *All*              5000       7,094
Access to moderator tools             *All*             10000       3,225
Protect questions                     *All*             15000       1,921
Perform trusted functions on the site *All*             20000       1,288
重要说明:


该查询名义上具有SEDE中包含的所有站点的数据(Stack Exchange,Data Explorer) )。
特权级别是从StackExchange API中获取的,在大多数情况下,这似乎是最新且准确的。
目前SEDE中没有特权级别表。
但是该API数据并不总是与FAQ一致...有时与特权页面并不总是一致


目前,SEDE查询无法得知站点数据它正在使用。因此,无论是否
它们都适用,将显示所有站点的特权要求。
DB_Name()DB_ID()函数可用于此目的。会在第二天或第二天进入查询。
样本表是手动过滤的,用于堆栈溢出。


#2 楼

答案接受率最高的用户

MinAnswers参数是所显示用户的最小答案数。好的值是50或10。

顺便说一句,看一下列表中的顶级用户,其中一些似乎正在以某种方式玩游戏:


User滑雪:21个已接受答案中的20个,全部都是悬赏,许多无用的答案。
伊尔沙德·侯赛因(Irshad Hussain)用户:10个已接受答案中的10个,几乎所有都是关于写作风格非常相似的用户提出的问题。


评论


我建议您对此发布特定的元支持请求,这些帐户应受到处罚

–华夫饼
2010年5月27日在21:42

我标记了它们以引起主持人注意。

– Interjay
10 May 27 '21:56

好一个!实际上,我已经想到了这个查询(也有这样的理由来查找sockpuppet帐户!),但是我不再考虑编写它了。

– BalusC
2010年5月27日23:44



#3 楼

关于元堆栈溢出的最常用评论:

Number Text 
------ ---------------------------------------------------------------------------------------------------------------------------
16      Yes ` ` ` ` ` ` 
12      
12      (-1) for the reasons in my answer. 
11      belongs on meta. 
 8      belongs on meta.stackoverflow.com 
 7      LOL ` ` ` ` ` ` 
 5      (-1) for the reasons in my response. 
 5      belongs on meta 
 5      FTFY! ` ` ` ` ` ` 
 5      No ` ` ` ` ` ` ` ` 
 5      Which browser are you using? 
 5      Why the downvote? 
 4      *facepalm* 
 4      [citation needed] 
 4      _` ` ` ` ` ` ` `_ 
 4      ` ` ` ` ` ` ` ` 
 4      http://meta.stackexchange.com/questions/4/list-of-stackexchange-sites 
 4      I agree. Definitely SOFU's fault. 
 4      Link or it didn't happen 
 4      Oh Crap. Temporal Causality loop. 
 4      see also http://meta.stackexchange.com/questions/42544/provide-some-kind-of-on-the-fly-translation-e-g-french-to-english 
 4      See: http://meta.stackexchange.com/questions/10369/what-was-stack-overflow-built-with 
 4      See: http://meta.stackexchange.com/questions/8401/where-can-i-ask-questions-that-arent-programming-questions 
 4      This belongs on meta.stackoverflow.com 
 4      Why? ` ` ` ` ` ` 


(第二个是一些Unicode空虚)


最重复的关于超级用户的评论

Number Text 
------ ---------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------- 
72     Belongs on superuser.com                                                                                                                                                                                                                                                                                                     
39     You're welcome.                                                                                                                                                                                                                                                                                                              
33     I've proposed a Stack Exchange-based Apple site that this question would be perfect for. Just go  [here](http://area51.stackexchange.com/proposals/151/apple?referrer=EmsxHuwirbI%3d) and click "Follow" to help get the site up and running.                                                                                
29     what operating system?                                                                                                                                                                                                                                                                                                       
29     you're more than welcome.                                                                                                                                                                                                                                                                                                    
28     belongs on superuser                                                                                                                                                                                                                                                                                                         
20     Belongs on SuperUser.                                                                                                                                                                                                                                                                                                        
18     **Avoid asking questions that are subjective, argumentative, or require extended discussion. This is not a discussion board, this is a place for questions that can be answered!**                                                                                                                                           
17     What OS are you using?                                                                                                                                                                                                                                                                                                       
14     Thank you very much!                                                                                                                                                                                                                                                                                                         
13     What operating system are you using?                                                                                                                                                                                                                                                                                         
13     You're more than welcome :)                                                                                                                                                                                                                                                                                                  
12     This is a website support issue. Not in the scope of SU.                                                                                                                                                                                                                                                                     
11     awesome, thanks!                                                                                                                                                                                                                                                                                                             
11     Sorry, but shopping type questions are discouraged on SU. http://meta.stackexchange.com/questions/36056/not-the-shopping                                                                                                                                                                                                     
11     Thanks, question answered!                                                                                                                                                                                                                                                                                                   
11     Which version of Windows?                                                                                                                                                                                                                                                                                                    
10     Should be community wiki.                                                                                                                                                                                                                                                                                                    
10     thank you very much                                                                                                                                                                                                                                                                                                          
10     why the downvote?                                                                                                                                                                                                                                                                                                            
10     You're most welcome.                                                                                                                                                                                                                                                                                                         
9      This belongs on SuperUser.com                                                                                                                                                                                                                                                                                                
9      You're most welcome :)                                                                                                                                                                                                                                                                                                       
9      You're most welcome!                                                                                                                                                                                                                                                                                                         
8      Hello, welcome to Super User. Your question has been migrated here, where it is more adapted. To regain ownership over your question, you should create an account here, and associate it with your Stack Overflow account in user options.                                                                                  
8      Outside the scope of SU. Try asking on one of the sites listed here: http://meta.stackexchange.com/questions/4                                                                                                                                                                                                               
8      Should be community wiki                                                                                                                                                                                                                                                                                                     
8      superuser is for computer hardware and software related questions only. Websites are considered off topic. Please read the FAQ (http://superuser.com/faq).                                                                                                                                                                   
8      Thank you for your answers!                                                                                                                                                                                                                                                                                                  
8      This is not computer related. Please check the FAQ for more information.                                                                                                                                                                                                                                                     
8      Which operating system?                                                                                                                                                                                                                                                                                                      
8      You're very welcome!                                                                                                                                                                                                                                                                                                         
8      You're welcome!                                                                                                                                                                                                                                                                                                              
7      I stand corrected.                                                                                                                                                                                                                                                                                                           
7      Should be a wiki.                                                                                                                                                                                                                                                                                                            
7      thanks for the link.                                                                                                                                                                                                                                                                                                         
7      This belongs on superuser.                                                                                                                                                                                                                                                                                                   
7      What version are you using?                                                                                                                                                                                                                                                                                                  
7      What version of windows?                                                                                                                                                                                                                                                                                                     
6      And http://superuser.com/questions/120461/transfer-time-of-a-cylinder                                                                                                                                                                                                                                                        
6      Community Wiki.                                                                                                                                                                                                                                                                                                              
6      Excellent, thanks!                                                                                                                                                                                                                                                                                                           
6      for what operating system?                                                                                                                                                                                                                                                                                                   
6      Glad I could help.                                                                                                                                                                                                                                                                                                           
6      Hello, welcome to Super User. Please review the FAQ (http://superuser.com/faq) to learn more about how this site works. This site is not a discussion board, this is a place for questions to be asked and answered. As such, you should not post a new answer if what you want to say doesn't actually answer the question. 
6      How is this programming related?                                                                                                                                                                                                                                                                                             
6      http://superuser.com                                                                                                                                                                                                                                                                                                         
6      I've raised http://meta.stackexchange.com/questions/45439/what-to-do-with-which-linux-distro-for-my-old-pc-questions-of-super-user/47075#47075 to discuss creating a faq about linux distributions. Please add any comments you have. Thanks.                                                                                
6      Ok great thanks!                                                                                                                                                                                                                                                                                                             
6      on what operating system?


显然,超级用户的用户主要是:


友好
复制粘贴他们的“详尽的解释”
寻求操作系统
(还有许多“属于SU”,这要归功于SO的迁移)

对默默无名的匿名人士的特别奖励宣传他的Apple建议。

评论


现在的游戏是:“找到最常说这些话的人”。我从(-1)开始:devinb!

– Gnoupi
2010年7月7日10:53



关于堆栈溢出:odata.stackexchange.com/stackoverflow/q/6358/…。大声笑“这是家庭作业吗?”

– kennytm
2010年7月7日,11:32

Math.SE是超级用户和堆栈溢出的组合:-)

–马克·赫德
2012年6月6日12:41

#4 楼

平均信誉得分最高,并在信誉国家中名列前茅的国家:

乔恩·斯基特(Jon Skeet)仅排名第三的排名!

Rank Country              NbCountryUsers TotalReputation RepsByUser User Link             LeaderReputation 
---- -------------------- -------------- --------------- ---------- --------------------- ---------------- 
 1   Germany               5764           7187046        1246       Pekka                 159384           
 2   Switzerland           1232           1442799        1171       marc_s                180050           
 3   United Kingdom       13946          15447312        1107       Jon Skeet             435230           
 4   New Zealand           1101           1217831        1106       Greg Hewgill          206714           
 5   Israel                1184           1285590        1085       Eli Bendersky          48880            
 6   United States        48776          48250718         989       Marc Gravell          306309           
 7   France                3150           3091885         981       Darin Dimitrov        311884           
 8   Bulgaria               447            430298         962       Bozho                 164212           
 9   Australia             4611           4355741         944       Stephen C             114909           
10   Netherlands           3145           2943495         935       Henk Holterman        101525           


评论


就目前而言,存在一个相当大的错误,因为“,”先映射到美国,再将“ UK”映射到英国,从而将(例如!)Marc Gravell归类为美国用户...

– AakashM
2012年6月6日15:22

库拉索岛(以前的荷属安的列斯)在哪里?

– BalusC
2012年6月6日15:26

您是否可以通过IP地址等方式确定这些人是否真正属于他们声称属于的地方?否则,这些统计信息将毫无意义。

–299792458
14年8月14日在6:05

#5 楼

网站的幸福感

显示的幸福感(%投票/总投票):



最不高兴的网站:



以及介于两者之间的任何地方。

评论


这令人印象深刻:)

–杰里米·汤普森(Jeremy Thompson)
17年7月9日在6:10

好玩! ...现在,您可以将其制成饼图吗?

–ashleedawg
18年7月30日在5:04

#6 楼

在Stack Overflow上找到也为您公司工作的人。

我找到了一些从我这里下班的人。如果您在大公司工作,有趣的东西。

#7 楼

前200名最高代表用户的每日投票频率

UpVotesPerDay

User Link                  Reputation Days UpVotes VotesPerDay             
-------------------------- ---------- ---- ------- ------------------- 
Eric Lippert               49208      447  1       0.00223713646532438 
unknown                    25372      364  76      0.208791208791209   
SQLMenace                  21322      690  214     0.310144927536232   
Red Filter                 20765      586  201     0.343003412969283   
:
KennyTM                    45356      208  2741    13.1778846153846    
Marc Gravell               151137     639  8547    13.3755868544601    
Pekka                      52537      263  4151    15.7832699619772    
Daniel Vassallo            34180      209  3321    15.88995215311      


DownVotesPerDay

User Link                  Reputation Days DownVotes VotesPerDay             
-------------------------- ---------- ---- --------- -------------------     
Mark Rushakoff             34783      375  0         0                   
sharptooth                 34226      525  0         0                   
Adam Davis                 28223      673  0         0                   
coobird                    22628      650  0         0                   
:
Tom Hawtin - tackline      28912      663  1939      2.92458521870287    
brian d foy                35890      652  2194      3.36503067484663    
David Dorward              41841      648  2400      3.7037037037037     
Neil Butterworth           83090      508  3476      6.84251968503937    


声誉

User Link       Reputation Days   Up Down UpPerDay           DownPerDay     
------------------------------------------------------------------------------
Jon Skeet       190431     641  6213  282  9.69266770670827  0.4399375975039     
Marc Gravell    151137     639  8547  456 13.3755868544601   0.713615023474178   
cletus          116287     649  2062  386  3.17719568567026  0.594761171032357   
Alex Martelli   115891     431   501   32  1.16241299303944  0.074245939675174   
tvanfosson      113772     651  3793  267  5.82642089093702  0.410138248847926   
JaredPar        102228     639  4412   62  6.90453834115806  0.0970266040688576  
Greg Hewgill     96521     689  3227  293  4.68359941944848  0.425253991291727   
paxdiablo        89650     651  1392  677  2.13824884792627  1.03993855606759    
Mehrdad Afshari  89075     603  1676  669  2.77943615257048  1.10945273631841    
S.Lott           87778     652  5403  543  8.28680981595092  0.832822085889571   


评论


我想知道谁有幸被埃里克·利珀特(Eric Lippert)推崇!

–丹尼尔·瓦萨洛(Daniel Vassallo)
10 Jul 18 '21:29

信誉链接的次要漏洞; @endDate必须声明为datetime,否则会发生以下错误,减法运算符中的数据类型date和datetime不兼容。

–凯尔·卡诺斯(Kyle Kanos)
15年8月18日在14:54

#8 楼

在Stack Overflow上最常见的问题标题:

Title                           Count 
------------------------------- ----- 
regular expression              33    
regular expression help         28    
help with sql query             21    
mysql query help                19    
jquery selector                 16    
sql query problem               15    
jquery selector question        14    
database design question        14    
regular expression question     13    
help with regular expression    13    
mysql query problem             12    
what's wrong with this code?    12    
android application development 12    


它们似乎大多与某种神奇的字符串选择器有关-正则表达式,SQL查询和jQuery选择器。

评论


这段代码怎么了?,很好,很好。

– BalusC
2011年2月11日在12:06

当前数据显示mysql越来越差,而regex甚至可以改善,但是未设置为对象实例的对象引用已达到顶峰。

–马克·赫德
13年3月23日在18:07

#9 楼

带有滑动平均值(平滑)的每日站点活动图:

此查询:

-- Displays a sliding average of questions, answers, and up/down votes per day
-- on a site. 
--
-- Parameters:
--
--    Days        Number of days to look back (relative to data dump date).
--    VScale      Divide vote counts by this number (for graph scaling).
--    WindowSize  Number of days (in addition to current) to include in
--                sliding average window (6 is a week, because 6+current = 7).
--                Set to 0 to see actual values instead of averages.
--
-- http://stackexchange.com/users/305991/jason-c

DECLARE @LastDate datetime
SELECT @LastDate = MAX(CreationDate) FROM PostHistory;

-- Hack to generate list of dates so we can insert dates with 0 items
-- into query below so that they're reflected accurately on the graph and
-- in sliding averages. Note we can't use recursion as max limit is 100 
-- on sede.
WITH DatesOfInterest AS (
  SELECT CONVERT(DATE, DATEADD(DAY, 1 - x.N, @LastDate)) D, y.W
  FROM (SELECT TOP ##Days?365## ROW_NUMBER() OVER (ORDER BY Id) N
        FROM PostHistory) x
  CROSS JOIN (SELECT *
        FROM (VALUES ('Questions'), ('Answers'), ('Votes / ' + STR(##VScale##))) z(W)) y
)

-- This query computes the sliding stats.
SELECT
  D [Date],
  W [What],
  AVG(N) OVER (PARTITION BY W ORDER BY D ROWS ##WindowSize?3## PRECEDING) AvgPerDay
FROM (
  -- This query adds 0's back in to daily events.
  SELECT 
    COALESCE(daily.D, doi.D) D,
    COALESCE(daily.W, doi.W) W, 
    COALESCE(daily.N, 0) N
  FROM 
    DatesOfInterest doi LEFT OUTER JOIN (  
      -- This query counts daily events.
      SELECT CONVERT(DATE, CreationDate) D, 'Questions' W, 1.0 * COUNT(*) N FROM Posts 
        WHERE PostTypeId = 1 AND DATEDIFF(DAY, CreationDate, @LastDate) <= ##Days##
        GROUP BY CONVERT(DATE, CreationDate)
      UNION SELECT CONVERT(DATE, CreationDate) D, 'Answers' W, 1.0 * COUNT(*) N FROM Posts 
        WHERE PostTypeId = 2 AND DATEDIFF(DAY, CreationDate, @LastDate) <= ##Days##
        GROUP BY CONVERT(DATE, CreationDate)
      UNION SELECT CONVERT(DATE, CreationDate) D, 'Votes / ' + STR(##VScale##) W, 1.0 * COUNT(*) / ##VScale?7## N FROM Votes 
        WHERE VoteTypeId IN (2, 3) AND DATEDIFF(DAY, CreationDate, @LastDate) <= ##Days##
        GROUP BY CONVERT(DATE, CreationDate)
    ) daily ON doi.D = daily.D AND doi.W = daily.W
  ) stats
ORDER BY
  [Date], 
  -- Custom sort order for the graph based on what I think looks good
  CASE W WHEN 'Answers' THEN 1 WHEN 'Questions' THEN 2 ELSE 0 END


可用于生成平均问题,答案的图,以及网站上每天的上/下投票,带有滑动窗口平均值以进行平滑。例如,西班牙语网站的窗口大小为90天,我们可以很好地了解网站随着时间的推移而增长:



并且窗口大小小得多当然可以提供更多有趣的短期信息。窗口大小0可以设置为仅直接显示值。请参阅查询顶部的注释。

#10 楼

我发现一个有趣的查询是“高标准”-与用户的声誉相比,它向用户显示的投票相对较少-因此,他们要么具有较高的投票标准,要么在某个时候忘记了“向上投票”按钮。前10个用户(使用MinRep = 10000,MinUpvotes = 0):

User Link              Ratio % Rep    + Votes - Votes 
---------------------- ------- ------ ------- ------- 
Eric Lippert           246000  49208  1       19      
Will Hartung           4628.13 14815  31      3       
gimel                  4059.46 15025  36      1       
unknown                3294.81 25372  76      29      
Guffa                  2835.35 56141  197     32      
Alex Martelli          2308.57 115891 501     32      
AndreyT                1994.12 30512  152     200     
CMS                    1875.68 83281  443     5       
John Feminella         1870.67 38913  207     8       
shahkalpesh            1821.43 10200  55      12


#11 楼

主要查询:最快获得徽章的人(固定的OBOE,并增加“自第一天起的天数”列)。




这些用户在2009-12-q成为{Legendary} 06,大概是徽章首次发布的日子。

User Link        DaysMembership
---------------- --------------
Alex Martelli    226
Reed Copsey      298
Mehrdad Afshari  399
Marc Gravell     434
JaredPar         435
Jon Skeet        437
cletus           444
tvanfosson       447


上述用户除外,它们是最快的前10名:

User Link            DaysMembership 
-------------------- -------------- 
polygenelubricants   192            
KennyTM              208            
Pekka                241            
Pascal MARTIN        262            
BalusC               266            
"Neil Butterworth"   329            
Pascal Thivent       429            
tvanfosson           447            
Mark Byers           457            
paxdiablo            495            


评论


好一个。就我而言,应该是75天,因为我的第一篇文章是注册后75天:P

– BalusC
2010年6月6日19:50

@BalusC:但是直到最近才引入了Epic / Legendary徽章,因此其他所有人的日期都可能不对。

–男士
2010年6月9日18:22

计数可能一天之内就会减少。要么是这样,要么就是Fanatic发生了什么:根据查询,成千上万的人成为会员后才获得了它。

–詹姆斯·麦克奈利斯
2010年6月21日,3:19

发烧友报告的是29天而不是30天。

–ChrisF♦
2010年6月21日在11:14

@mmyers:它们是在我接触Epic的前几天才介绍的,所以仍然按时进行:) Mortarboard但是“太迟了”。根据我的/信誉页面,我已经在自己的SO活动的第二天点击了它。

– BalusC
2010年7月6日15:49



@tvanfosson出现在两个列表中...

– davidsleeps
2011-12-12 22:21

#12 楼

在前200个标签中具有可接受答案的问题百分比:

Tag                    TotalQuestion TotalAccepted Percentage 
---------------------- ------------- ------------- ---------- 
generics               2795          2313          82         
string-manipulation    1606          1316          81         
reflection             2257          1789          79         
tsql                   4299          3420          79         
string                 4068          3211          78         
arrays                 4625          3618          78         
regex                  8796          6862          78         
...
android                11134         5727          51         
pdf                    2114          1058          50         
server                 1704          820           48         
facebook               2150          839           39     


#13 楼

每小时用户活动的分布

这是krock进行的流行查询的更新,并且看起来很不错。

#14 楼

由于目前没有时间投票,因此我按帖子的每个时间和每个工作日的时间进行投票:

堆栈溢出工作日时间每周工作时间
-接受的工作日工作时间一周

元堆栈溢出工作日工作时间小时数

分析:堆栈溢出:最好在(UTC?)一天的23小时内提问星期二,但任何工作日都可以。在星期日的7个小时问一个问题,您有23%(一天)或60%(小时)的投票率降低。

无论白天还是以前,答案都更加统一。

元堆栈溢出:完全不同的字符(如预期的那样)–要求的最差时间是星期五的23小时(当然),最好的时间是周日18小时。与前者相比,前者有58.5%(天)或85.4%(小时)的可能性更高。

MetaStack上的答案最好在星期五的21小时发布,并且最有可能在星期四0时收到否决票。

编辑:看到我将最佳和最差时间描述为平日时,我已经包括了该实际查询。因此,实际上,堆栈溢出的最佳时间是23周四(问题)和23周三(答案),最坏的时间是7周日(问题)和1周六(答案)。

元堆栈溢出实际上没有太多的否决票将其分解为一周的几个小时,但无论如何,最好的问题是4个星期日,问题的答案是8个星期一,最糟糕的是问题是3个星期四,问题的答案是12个星期天。 :添加了堆栈溢出接受的答案分析。请注意,最新的月度结果已更改了上面的分析,因此堆栈溢出和元堆栈溢出行为尚未完全解决。

#15 楼

以下是一些令我感兴趣的查询:



每天rep排名前50位用户


我写的原始查询是这是基于。有人称它为“新星”;我不认为乔恩·斯基特(Jon Skeet)是后起之秀。他是宇宙的不断扩展的边缘。
一旦我学习了足够多的SQL,就会做最近30天的版本。



另请参阅:请求最近30天的顶级用户阶梯





按奖励数量划分的主要用户
按徽章数(各种类型)排名的用户
按徽章数排名的用户
每天


评论


很好的查询!但是..嘿,我已经连续255天没有活动了!在实际开始发布第一个答案之前,我注册了一个半月;)

– BalusC
2010年5月26日在18:16



@BalusC:是的,我知道,这就是为什么我争取正式的“过去30天”顶级用户阶梯。我将弄清楚如何尽快编写查询,或者您可以编写查询,然后我将从中学习。

–多基因润滑剂
2010年5月26日在18:22



回复:徽章赚钱者很快,我们在徽章表上缺少日期,已经提交的修复将在几天之内进行下一次数据转储

–华夫饼
2010年5月27日在21:39

@waffles:让我成为管理员=)

–多基因润滑剂
2010年5月28日在9:25



有人可以解决第一个查询吗?

–维尔纳
2014年12月14日在7:13

请帮助我:meta.stackoverflow.com/questions/389757/…

–阿德里塔·夏尔马
19-09-25在7:21

#16 楼

(这些仅是暂时的概念查询;它可能应该是一条注释,但是由于这是CW,所以我将其作为“答案”摆放了下来-每个人都可以自由地接受它并实际使用它。如果没有人选择它, ,我相信我将学到足够的SQL知识,最终能够自己编写这些查询。)


在所有投票中,有多少百分比是在5分钟内问题被张贴?一个小时之内?一天之内?一周?一个月?六个月?等。


(似乎普遍接受的假设是,大多数投票发生在问题生命的早期阶段,因此很高兴看到这一点得到了数据的支持)


哪个非CW回答连续不断地trick激投票,在写完后的几天,几周,几个月? “旧版”答案看起来像是什么,通常是关于什么的问题,等等。(因为是的,我希望自己拥有尽可能多的问题)。

评论


对于您的第一个查询,我有此信息:odata.stackexchange.com/stackoverflow/q/7920/…。但是没有对数标度,我可能做错了,因为在创建他们的帖子之前我有很多票。当数据转储提供可视化效果时,它看起来会更好(我正在考虑添加自己)。

–科比
2010年7月21日在4:54

我注意到今天有钱用于果酱和我的钱用于果酱查询。那些似乎遵守了这一要求。确实非常有趣的数据:)

– BalusC
2010年7月29日在23:03

那些是可点击的:)对不起,格式化为代码,我应该更好地了解:meta.stackexchange.com/questions/48560/…

– BalusC
2010年7月30日12:02



#17 楼

当每个人都下班时,这些用户仍然在这里为您提供帮助。
我的第一个无用data.stackexchange查询!我开始熟悉该架构(希望如此)!

#18 楼

大奥秘
此查询将使您看到没有答案的问题,该问题的分数为正且至少具有五个投票数:
http://data.stackexchange.com/stackoverflow/s/414/great- mystery-badge
这是我对我的徽章主张提出的查询:
其他徽章创意

#19 楼

这是一个查询,以检索您喜欢的帖子的ID。

评论


它向用户显示了最喜欢的内容。

–马修·克鲁姆利
10年7月29日在5:36

固定的。 。 。 。 。

–明胶
10年7月29日在14:26

#20 楼

搜索与某些[tag]匹配的Stack Overflow收藏夹。

当Stack Overflow上有成百上千个收藏夹时,通常只想查找与某个标签匹配的收藏夹。新的搜索引擎消除了使用infavortes: tag进行搜索的能力,因此,只要您仅需要搜索标签名称,它就可以代替该功能。

#21 楼

为汉兰达徽章建议创建的查询。

http://data.stackexchange.com/stackoverflow/s/415/highlander-badge

评论


cf. meta.stackexchange.com/questions/59123/…

–多基因润滑剂
10年7月31日在7:28



#22 楼

您的编辑评论

向您显示您批准了多少次并且编辑被批准了,您拒绝了,但是编辑被批准了,您批准了但是编辑被拒绝了,然后您拒绝了,并且编辑被拒绝了。 br />
示例结果:

+-------+----------+----------+
| Count | You...   | They...  |
|-------+----------+----------+
|   672 | Approved | Approved |
|-------+----------+----------+
|    96 | Rejected | Approved |
|-------+----------+----------+
|     9 | Approved | Rejected |
|-------+----------+----------+
|   253 | Rejected | Rejected |
+-------+----------+----------+



您的错误建议编辑评论

将您链接到您的评论您批准但编辑被拒绝的信息。

帖子的评论

显示指定帖子的所有类型的所有评论。

#23 楼

投票最高的回答率
基于“接受的回答率”查询,给出您所拥有答案的百分比,其中答案是对该问题的最高票数,并且至少有一票。基本上是一种“社区接受的答案”的量度,因为问问者并不总是接受一个答案,或者接受一个社区可能认为不太有用的答案。

#24 楼

My Money For Jam,改进

这是对流行的My Money For Jam查询的改进,该查询的运行速度提高了大约10倍(2.6秒,而Jon Skeet为22.4秒)。

以下是经过改进的查询:

DECLARE @LatestDate DATETIME
SELECT @LatestDate = MAX(CreationDate) FROM Posts
DECLARE @IgnoreDays NUMERIC = 15
DECLARE @MinAgeDays NUMERIC = 60

SELECT TOP 100
  PostId [Post Link],
  1.0 * ([Passive Up Reputation] - [Passive Down Reputation]) / [Days Counted] [Passive Rep Per Day],
  [Passive Up Reputation] - [Passive Down Reputation] [Passive Rep],
  [Passive Up Reputation],
  [Passive Down Reputation],
  [Days Counted]
FROM (
  SELECT
    v.PostId,
    SUM(CASE WHEN v.VoteTypeId = 2 THEN
      CASE WHEN p.PostTypeId = 1 THEN 5 ELSE 10 END
      ELSE 0 END) [Passive Up Reputation],
    SUM(CASE WHEN v.VoteTypeId = 3 THEN 2 ELSE 0 END) [Passive Down Reputation],
    DATEDIFF(DAY, p.CreationDate, @LatestDate) - @IgnoreDays [Days Counted]
  FROM
    Votes v
    INNER JOIN Posts p ON p.Id = v.PostId
  WHERE
    v.VoteTypeId IN (2, 3)
    AND p.CommunityOwnedDate IS NULL
    AND DATEDIFF(DAY, p.CreationDate, @LatestDate) > @MinAgeDays
    AND DATEDIFF(DAY, p.CreationDate, v.CreationDate) > @IgnoreDays
    AND p.OwnerUserId = ##UserId##
  GROUP BY
    v.PostId, p.CreationDate
  ) x
ORDER BY
  [Passive Rep Per Day] DESC


可以删除TOP 100,它仅是为了与现有的My Money For Jam查询兼容。

现在,它已经足够快地成为整个网站上所有用户的前500名,这是我在这里的主要目标:

DECLARE @LatestDate DATETIME
SELECT @LatestDate = MAX(CreationDate) FROM Posts
DECLARE @IgnoreDays NUMERIC = 15
DECLARE @MinAgeDays NUMERIC = 60

SELECT TOP 500
  PostId [Post Link],
  OwnerUserId [User Link],
  1.0 * ([Passive Up Reputation] - [Passive Down Reputation]) / [Days Counted] [Passive Rep Per Day],
  [Passive Up Reputation] - [Passive Down Reputation] [Passive Rep],
  [Passive Up Reputation],
  [Passive Down Reputation],
  [Days Counted]
FROM (
  SELECT
    v.PostId,
    p.OwnerUserId,
    SUM(CASE WHEN v.VoteTypeId = 2 THEN
      CASE WHEN p.PostTypeId = 1 THEN 5 ELSE 10 END
      ELSE 0 END) [Passive Up Reputation],
    SUM(CASE WHEN v.VoteTypeId = 3 THEN 2 ELSE 0 END) [Passive Down Reputation],
    DATEDIFF(DAY, p.CreationDate, @LatestDate) - @IgnoreDays [Days Counted]
  FROM
    Votes v
    INNER JOIN Posts p ON p.Id = v.PostId
  WHERE
    v.VoteTypeId IN (2, 3)
    AND p.CommunityOwnedDate IS NULL
    AND DATEDIFF(DAY, p.CreationDate, @LatestDate) > @MinAgeDays
    AND DATEDIFF(DAY, p.CreationDate, v.CreationDate) > @IgnoreDays
  GROUP BY
    v.PostId, p.CreationDate, p.OwnerUserId
  ) x
ORDER BY
  [Passive Rep Per Day] DESC


#25 楼

活跃在Main和Meta上的用户百分比

截至2017年4月2日,这是前20名:

Site                             Active Main Active Meta Active Both Fraction Active
                                                                        On Both 
-------------------------------- ----------- ----------- ----------- --------------- 
StackExchange.Devops             387         122         119         0.307493540051          
StackExchange.Vegetarian         284         87          84          0.295774647887          
StackExchange.Ukrainian          223         62          61          0.273542600896          
StackExchange.Korean             107         25          24          0.22429906542           
StackExchange.Literature         617         133         133         0.215559157212          
StackExchange.Portuguese         170         33          33          0.194117647058          
StackExchange.Languagelearning   150         31          29          0.193333333333          
StackExchange.Judaism            745         135         129         0.173154362416          
StackExchange.Codegolf           7506        1282        1267        0.168798294697          
StackExchange.Latin              288         47          45          0.15625                 
StackOverflow.Es                 3111        467         459         0.147540983606          
StackExchange.Moderators         118         17          17          0.14406779661           
StackExchange.Sitecore           542         79          77          0.142066420664          
StackExchange.Scifi              8367        1196        1158        0.138400860523          
StackExchange.Esperanto          138         19          19          0.13768115942           
StackExchange.Math               40068       5672        5474        0.136617749825          
StackExchange.Hermeneutics       360         51          49          0.136111111111          
StackExchange.Musicfans          302         45          41          0.135761589403          
StackExchange.Chemistry          2479        344         333         0.134328358208          
StackExchange.Hinduism           450         70          59          0.131111111111          



单个站点

此查询可以在单个站点上运行,并输出在主站点上活动的用户数,元站点和两者,以及在meta上活动的主要用户的比例。可以设置活动日期范围和最低代表阈值:

-- To run this query select a *main* site. The corresponding meta site will
-- be automatically queried. Does not work on MSE or StackApps.
--
-- Output is number of users recently active on main, meta, both, and the
-- fraction of users active on main who are also active on both.
--
-- https://meta.stackexchange.com/a/293155

CREATE TABLE #Results ([Active Main] INT, [Active Meta] INT, [Active Both] INT)

DECLARE @Query NVARCHAR(MAX) =
  'INSERT INTO #Results SELECT
    COUNT(main.Id) [Active Main],
    COUNT(meta.Id) [Active Meta],
    COALESCE(SUM(CASE WHEN main.Id IS NOT NULL AND meta.Id IS NOT NULL THEN 1 ELSE 0 END), 0) [Active Both]
  FROM
    (SELECT Id FROM Users WHERE Reputation > ##MinReputation?1##
     AND DATEDIFF(DAY, LastAccessDate, GETDATE()) <= ##ActiveDays?30##) main
    FULL OUTER JOIN 
    (SELECT Id FROM [' + DB_NAME() + '.Meta].dbo.Users WHERE Reputation > ##MinReputation##
     AND DATEDIFF(DAY, LastAccessDate, GETDATE()) <= ##ActiveDays##) meta
    ON main.Id = meta.Id'

EXEC(@Query)

SELECT 
  *,
  CASE WHEN [Active Main] > 0 
  THEN 1.0 * [Active Both] / [Active Main]
  ELSE 0 END [Fraction Active On Both]
FROM #Results





所有站点

该查询显示与上述相同的信息,但针对每个站点。:

-- Output is number of users recently active on main, meta, both, and the
-- fraction of users active on main who are also active on both. Excludes MSE
-- and StackApps, which do not have a corresponding meta.
--
-- https://meta.stackexchange.com/a/293155

DECLARE @db SYSNAME
DECLARE @Query NVARCHAR(max)
DECLARE c CURSOR FOR 
  SELECT Name 
  FROM sys.databases 
  WHERE database_id > 5
  AND name NOT LIKE '%.Meta'
  AND name NOT LIKE 'StackApps%'

CREATE TABLE #Results ([Site] NVARCHAR(100), [Active Main] INT, [Active Meta] INT, [Active Both] INT)

OPEN c
FETCH NEXT FROM c INTO @db
WHILE (@@FETCH_STATUS = 0) BEGIN
  SET @Query =
    'INSERT INTO #Results SELECT
      ''' + @db + ''' [Site],
      COUNT(main.Id) [Active Main],
      COUNT(meta.Id) [Active Meta],
      COALESCE(SUM(CASE WHEN main.Id IS NOT NULL AND meta.Id IS NOT NULL THEN 1 ELSE 0 END), 0) [Active Both]
    FROM
      (SELECT Id FROM ' + QUOTENAME(@db) + '.dbo.Users WHERE Reputation > ##MinReputation?1##
       AND DATEDIFF(DAY, LastAccessDate, GETDATE()) <= ##ActiveDays?30##) main
      FULL OUTER JOIN 
      (SELECT Id FROM ' + QUOTENAME(@db + '.Meta') + '.dbo.Users WHERE Reputation > ##MinReputation##
       AND DATEDIFF(DAY, LastAccessDate, GETDATE()) <= ##ActiveDays##) meta
      ON main.Id = meta.Id'
  EXEC(@Query)
  FETCH NEXT FROM c INTO @db
END;
CLOSE c;
DEALLOCATE c;

SELECT 
  *,
  CASE WHEN [Active Main] > 0 
  THEN 1.0 * [Active Both] / [Active Main]
  ELSE 0 END [Fraction Active On Both]
FROM 
  #Results
ORDER BY
  [Site]


#26 楼

您在网络范围内的热门评论


这里是查询。您需要您的网络帐户ID,该ID可从您的个人资料URL(网址为https://stackexchange.com)获得。插入它,您的所有网站上的热门评论就会显示出来,并带有可单击的链接。

这里是一个在全球范围内显示热门评论的版本。

不用担心,包括来源,可以在上面的链接中找到。

如果有人好奇,在撰写本文时,这是整个网络上投票率最高的评论。

#27 楼

列出按标签名称赢得的赏金
我只是想掌握SQL Server语法,因此它具有要查找的三个独立标签的数量,但是随着这些事情的发生,列出交错在一起的几个标签的赏金似乎很有用。

#28 楼

平均答案得分可能会因为一个好答案而大大偏离。我认为最好使用中位数来更好地了解用户的“平均”效果:


我的中位数答案得分:

SELECT 
    Count(Posts.Id) AS Answers,
    (SELECT MAX(Score) 
     FROM (SELECT TOP 50 percent Score
           FROM Posts as PU
           WHERE PostTypeId = 2 and CommunityOwnedDate IS NULL and PU.OwnerUserId = ##UserId##
           ORDER BY Score
           ) as t
     ) AS MedianAnswerScore
FROM
    Posts
WHERE 
    PostTypeId = 2 and CommunityOwnedDate IS NULL and OwnerUserId = ##UserId##



中位数回答分数最高的用户:

SELECT 
    TOP 100
    Users.Id,
    DisplayName,
    Count(Posts.Id) AS Answers,
    (SELECT MAX(Score) 
     FROM (SELECT TOP 50 percent Score
           FROM Posts as PU
           WHERE PostTypeId = 2 and CommunityOwnedDate IS NULL and PU.OwnerUserId = Users.Id
           ORDER BY Score
           ) as t
     ) AS MedianAnswerScore
FROM
    Posts
  INNER JOIN
    Users ON Users.Id = OwnerUserId
WHERE 
    PostTypeId = 2 and CommunityOwnedDate IS NULL
GROUP BY
    Users.Id, DisplayName
HAVING
    Count(Posts.Id) > 100
ORDER BY
    MedianAnswerScore DESC


#29 楼

每个站点的批准/拒绝建议编辑的百分比
我很无聊,没有任何东西可以像统计数据一样解决无聊!
此查询基于每个站点(基于总体结果)获取建议编辑的批准/拒绝而不是按用户投票数细分)。您有时会觉得一个网站似乎比其他网站拒绝更多建议吗?检查并查找!

喊话:
可以查询所有从此meta偷来的网站的可能性

注意事项:
元网站也包括在内查询,但是由于元站点的性质,建议在这些站点上的批准/拒绝是

,但数量太少,无法认真地视为“模式”
偏向“已批准”由于用户建议进行修改(关注网站/规则的内容),或者
根本不存在(尤其是在较小的网站上)


#30 楼

金牌徽章持有者(在该问题的标签上)张贴的可接受答案的百分比:

with AcceptedAnswers as
(
  select a.ParentId QuestionId, a.Id AnswerId, a.OwnerUserId
  from Posts a
  where PostTypeId=2
  and exists (select 1 from Posts q where q.AcceptedAnswerId=a.Id)
)

select Format(count(*)*1.0/(select count(*) from AcceptedAnswers), 'P') PctGoldBadgeAcceptedAnswers
from AcceptedAnswers aa
where exists (select 1 
  from PostTags pt
  join Tags t on t.Id=pt.TagId
  join Badges b on b.Name=t.TagName and TagBased=1 and Class=1
  where pt.PostId=aa.QuestionId
    and b.UserId=aa.OwnerUserId)


积分转到Shog9。