QuerySetId
uint32
466
1.35M
Title
stringlengths
4
100
Description
stringlengths
1
994
QueryBody
stringlengths
1
799
CreationDate
stringlengths
19
19
validated
bool
1 class
10,814
50 Newest Users with >= X Reputation
SELECT TOP 50 Id as [User Link], Reputation, 1+DateDiff(Day, CreationDate, GETDATE()) As [DaysMembership] FROM Users WHERE Reputation >= '##Cutoff##' ORDER BY DaysMembership ASC
2010-09-12 22:25:33
false
11,255
Find user by display name
Because partial searches don't work on the live site anymore
SELECT Id as [User Link], Reputation, EmailHash FROM Users WHERE DisplayName LIKE '%##DisplayName##%' -- Enter Query Description
2010-09-17 01:29:32
false
11,381
How many images have been uploaded to the site?
Counts the number of posts containing images hosted by imgur.com after image uploading was implemented on the site.
WITH c AS ( SELECT OwnerUserId, Body, 1 AS t FROM Posts WHERE CreationDate >= 'August 13, 2010' -- http://meta.stackoverflow.com/q/60782 ) SELECT OwnerUserId AS [User Link], SUM(t) AS Count FROM c WHERE Body LIKE '%imgur.com%' GROUP BY OwnerUserId WITH ROLLUP ORDER BY SUM(t) DESC
2015-04-07 16:39:41
false
11,438
Are you one of the top SO-users in your country or state?
As in the title. Depends on what people type into the country description.
SELECT reputation, id as [User Link], location, age from users where location like '%##country##%' order by reputation desc
2012-06-29 00:25:36
false
11,483
Users with Largest difference between highest scoring answer and lowest scoring answer
Enter Query Description
DECLARE @HighScoreLimit int = ##HighScoreLimit## SELECT Top 100 Max(Score) High, Min(Score) Low, Max(Score) - MIN(Score) Delta, OwnerUserId [User Link] FROM posts GROUP BY OwnerUserId HAVING Max(Score) <= @HighScoreLimit ORDER BY Delta Desc
2010-09-21 01:04:40
false
11,670
Find Gaps in Post IDs
Sample for SO Question 3788552 SQL interview question
SELECT low, high FROM ( SELECT ID, low FROM (SELECT n1.ID ID, min(n2.ID) + 1 low from posts n1 inner join posts n2 on n1.ID < n2.ID WHERE n1.ID < 5000 and n2.ID < 5000 Group by n1.ID) t WHERE t.low not in (SELECT ID FROM posts) and t.low < (SELECT MAX(ID) from posts) ) t INNER JOIN ( SELECT ID - 1 ID, high FROM (SELECT n1.ID ID , min(n2.ID) - 1 high from posts n1 inner join posts n2 on n1.ID < n2.ID WHERE n1.ID < 5000 and n2.ID < 5000 Group by n1.ID) t WHERE t.high not in (SELECT ID FROM posts) ) t2 ON t.ID = t2.ID
2010-09-24 20:56:10
false
11,730
Questions that don't have any required tags (Meta sites only)
Finds all questions without one of: [support], [discussion], [feature-request], [bug].
WITH out one of: [support], [discussion], [feature-request], [bug]. WITH RequiredTagIds AS ( SELECT Id FROM Tags WHERE TagName IN ('support', 'discussion', 'feature-request', 'bug') ) SELECT p.Id AS [Post Link], p.ClosedDate FROM Posts p WHERE (p.PostTypeId = 1) AND NOT EXISTS ( SELECT * FROM PostTags pt WHERE (pt.PostId = p.Id) AND (pt.TagId IN (SELECT Id FROM RequiredTagIds)) ) ORDER BY p.ClosedDate DESC
2010-09-26 22:54:54
false
11,868
Number of Votes per Month
The total number of votes (upvotes and downvotes) per month
SELECT UpVotes, DownVotes FROM users WHERE id = ##userid##
2012-03-02 02:13:34
false
11,879
Average Number of Votes on Answers per Month
The average number of votes (upvotes and downvotes) on answers per month
SELECT YEAR(v.CreationDate) year, MONTH(v.CreationDate) month, CAST(COUNT(*) AS float) / ( SELECT CAST (COUNT(*) AS float) FROM posts p WHERE YEAR(p.CreationDate) = YEAR(v.CreationDate) AND MONTH(p.CreationDate) = MONTH(v.CreationDate) AND p.PostTypeId = 2 ) votes_per_answer FROM votes v INNER JOIN posts p ON (p.id = v.postid AND p.PostTypeId = 2) where YEAR(v.CreationDate) >= 2012 GROUP BY YEAR(v.CreationDate), MONTH(v.CreationDate) ORDER BY 1 DESC, 2 DESC
2015-08-13 00:27:52
false
11,937
Users with lots of poor-scoring answers
Specify maximum answer score and minimum number of answers
DECLARE @ScoreThreshold int = ##ScoreThreshold## DECLARE @AnswerThreshold int = ##AnswerThreshold## Select OwnerUserId As [User Link], (Select Count(*) From Posts p Where p.OwnerUserId=Posts.OwnerUserId And Score<=@ScoreThreshold And posttypeid=2 And communityowneddate is Null) * 100.0 / Count(*) As [% Below Threshold], Count(*) As [Total Answers] From Posts Where posttypeid=2 And communityowneddate is Null Group By owneruserid Having Count(*) > @AnswerThreshold Order By [% Below Threshold] Desc
2010-10-01 02:46:24
false
12,006
Whats the age demographic per tag?
I tried to make this accept the tag as a parameter but I kepy getting an error.
DECLARE @TagParam varchar = ##TagParam## SELECT TagName, count(TagName) as TagsPerAge, Age FROM Tags INNER JOIN PostTags ON PostTags.TagId = Tags.id INNER JOIN Posts ON Posts.ParentId = PostTags.PostId INNER JOIN Users ON Users.id = Posts.OwnerUserId WHERE TagName = 'php' AND age > 0 GROUP BY Age, TagName ORDER BY TagsPerAge DESC
2010-10-02 00:57:20
false
12,192
High on favorites, but low on votes
Find out which questions were favorited more than twice their score
SELECT Id as [Post Link], FavoriteCount, Score from Posts where Score > 10 and FavoriteCount > 10 order by FavoriteCount desc
2013-02-16 20:12:27
false
12,432
Question and answer counts group by hour
Find the most quiet moment to ask or answer questions
SELECT q.hour AS [UTC Hour], CAST(q.questions AS varchar) + ' (' + CAST(q.percentage AS varchar) + '%)' AS Questions, CAST(a.answers AS varchar) + ' (' + CAST(a.percentage AS varchar) + '%)' AS Answers FROM (SELECT DATEPART(hour, CreationDate) AS hour, COUNT(*) AS questions, 100.0 * COUNT(*) / (SELECT COUNT(*) FROM Posts WHERE PostTypeId = 1) AS percentage FROM Posts WHERE PostTypeId = 1 GROUP BY DATEPART(hour, CreationDate) ) q INNER JOIN (SELECT DATEPART(hour, CreationDate) AS hour, COUNT(*) AS answers, 100.0 * COUNT(*) / (SELECT COUNT(*) FROM Posts WHERE PostTypeId = 2) AS percentage FROM Posts WHERE PostTypeId = 2 GROUP BY DATEPART(hour, CreationDate) ) a ON q.hour = a.hour ORDER BY --q.hour, questions, answers
2012-12-19 16:19:39
false
12,879
Nice persons (top 500 users ordered by profile views per day)
null
SELECT TOP 500 ROW_NUMBER() OVER (ORDER BY [Views per Day] DESC) AS [#], * FROM ( SELECT u.Id AS [User Link], u.Views, u.Reputation, 1. * u.Views / DATEDIFF(d, CreationDate, GETDATE()) AS [Views per Day] FROM Users u ) q ORDER BY [Views per Day] DESC
2015-05-25 16:53:41
false
13,007
Top 100 users having highest votes per day ratio
Lists top 100 users who have highest votes/day ratio excluding community user and minimum of 100 votes cast. Uncomment last line to filter by id.
SELECT id [User Link] , datediff(dd, creationdate, GETDATE() )"Days" ,(upvotes+downvotes) "Votes" , round(cast(nullif((upvotes+downvotes), 0)as float) / datediff(dd, creationdate, GETDATE()),4) "Votes/Day Ratio" from users where id = 59435 and (upvotes+downvotes)> 100 -- and id = ##User_ID## order by "Votes/Day Ratio" desc
2013-04-24 22:22:35
false
13,151
Q's with no A's >= 0 after three months
Finds number of questions that have no accepted answer and no answers with a score >= 0 after three months
WITH no A's >= 0 after three months -- Finds number of questions that have no accepted answer and no answers WITH a score >= 0 after three months select count(*), Min(CreationDate), Max(CreationDate), Count(Distinct OwnerUserId) from posts as q where PostTypeId=1 AND Score < 1 AND CreationDate < DATEADD(MONTH, -3, GETDATE()) AND ClosedDate is null and AcceptedAnswerId is null AND NOT EXISTS ( select * from posts as a where PostTypeId=2 and ParentId=q.id and Score>=0 )
2012-08-17 10:06:01
false
13,152
View Deadweight (Phase 2) questions
View latest questions older than 3 months that have score < 1 and all answers have score < 0
SELECT id as [Post Link],Title,Body from posts as q where PostTypeId=1 AND Score < 1 AND CreationDate < DATEADD(MONTH, -3, GETDATE()) AND ClosedDate is null and AcceptedAnswerId is null AND AnswerCount > 0 AND NOT EXISTS ( SELECT * from posts as a where PostTypeId=2 and ParentId=q.id and Score>=0 ) ORDER BY CreationDate DESC
2010-10-22 19:02:23
false
13,283
DEMO for Need help with a complex SQL query
http://stackoverflow.com/q/4015915/119477
WITH a complex SQL query -- http://stackoverflow.com/q/4015915/119477 SELECT DISTINCT t2.TagName Other from tags t INNER JOIN postTags pt ON t.id = pt.tagid INNER JOIN postTags pt2 ON pt.PostId = pt2.PostId INNER JOIN tags t2 on pt2.Tagid = t2.id where t.tagname = 'MySQL'
2010-10-25 19:58:24
false
13,348
Count the Number of Questions with No Answer Post
null
WITH No Answer Post select count(id) as "Number of Questions WITH No Answer Post" from Posts where AnswerCount = 0
2010-10-27 18:02:48
false
13,932
How many upvotes do I have for each tag? Non-wiki
how long before I get tag badges?
DECLARE @UserId int = ##UserId## 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 and VoteTypeId = 2 WHERE Posts.OwnerUserId = @UserId and communityowneddate is null GROUP BY TagName ORDER BY UpVotes DESC
2010-11-11 01:10:35
false
13,964
Average Reputation Of All Users
This will tell you the average reputation of all users.
DECLARE @MinimumReputation int = ##MinimumReputation## SELECT SUM(Reputation) AS "Total Reputation", COUNT(Id) AS "User Count", SUM(Reputation) / COUNT(Id) AS "Average Reputation" FROM Users WHERE Reputation >= @MinimumReputation;
2010-11-11 14:47:40
false
14,151
Number of questions per month
Number of questions per month
SELECT year(CreationDate), month(CreationDate), count(*) from Posts where ParentId is null group by year(CreationDate), month(CreationDate) order by 1 desc, 2 desc
2010-11-13 21:38:55
false
14,517
Keystrokes per rep point (lower limit)
Ranks users with over 1000 reputation points by how many characters they needed to type to achieve that reputation (counts title and body characters)
WITH over 5000 reputation points by how many characters they needed to type to achieve that reputation (counts title and body characters) Select u.Id As [User Link], (sum(coalesce(datalength(p.Body),0)) + sum(coalesce(datalength(p.Title),0))) As keystrokes, u.Reputation, (sum(coalesce(datalength(p.Body),0)) + sum(coalesce(datalength(p.Title),0)))/u.Reputation As rate From users u, posts p Where p.OwnerUserId = u.Id And u.Reputation >= 1000 Group By u.Id, u.Reputation Order By rate Asc
2017-04-19 19:02:53
false
14,647
Number of questions per day
null
SELECT AVG(c) AS AvgQuesPerDay FROM ( SELECT year(CreationDate) AS y, month(CreationDate) AS m, day(CreationDate) AS d, count(*) AS c from Posts where ParentId is null and CreationDate > DATEADD(DAY, -90, CURRENT_TIMESTAMP) group by year(CreationDate), month(CreationDate), day(CreationDate) ) AS t
2018-12-01 21:35:21
false
15,490
Which of my answers are unsung?
Zero and non-zero accepted answers. Self-accepted answers do not count.
SELECT a.score, q.title, q.Tags from Posts q inner join Posts a on a.Id = q.AcceptedAnswerId where a.CommunityOwnedDate is null and a.OwnerUserId = ##UserId## and q.OwnerUserId != ##UserId## and a.score =0 and a.postTypeId = 2 order by q.Tags
2015-08-11 14:18:49
false
15,901
How is your favourite language/tag doing on SO?
Shows the trend for your favourite tag
SELECT * from tags order by count desc;
2018-04-26 17:47:07
false
16,111
MELS questions with answers and votes
null
WITH answers and votes SELECT p.id, p.title, count(answers.id) answerCount , p.Score, count(answers.id)-p.Score as subtraction FROM posts p INNER JOIN posts answers ON p.id = answers.parentId INNER JOIN (SELECT postid, Count(v.id) votes FROM posts p INNER JOIN posts answers ON p.id = answers.parentId INNER JOIN votes v ON p.id = v.postID WHERE p.postTypeId = '1' --- and p.OwnerUserID = 276959 GROUP BY postid) v on v.postID = p.id WHERE p.postTypeId = '1' --- and p.OwnerUserID = 276959 GROUP BY --v.votes, p.Score , p.id, p.title
2015-09-01 15:12:17
false
16,303
Combined Reputation of Bottom X% of Users
Determines the combined reputation of all users, excluding the specified top percent
WITH Rankings AS ( SELECT Id, Reputation, Ranking = ROW_NUMBER() OVER(ORDER BY Reputation DESC) FROM Users ) , Counts AS ( SELECT Count = COUNT(*) FROM Users ), RankedUsers AS ( SELECT Reputation, CAST(Ranking AS decimal(10, 5)) / (SELECT Count FROM Counts) AS Percentile FROM Rankings ) SELECT SUM(Reputation) AS "Combined Reputation", COUNT(*) AS "# Users Represented" FROM RankedUsers WHERE Percentile > ##ExcludingTopPercent## / 100.0
2010-12-15 21:12:01
false
16,630
Select random non-closed, non-cw answers
Enter Query Description
SELECT TOP 1000 len(body) as body_len, score FROM posts WHERE communityowneddate is null and closeddate is null and PostTypeId = 2 order by NEWID()
2010-12-19 10:13:13
false
16,722
How many questions have been posted on 2010-12-01?
Counts the number of posts on a given day
SELECT count(Id) as [Questions posted] from Posts where CreationDate > '2010-12-01 00:00' and CreationDate < '2010-12-01 23:59:59' and PostTypeId = 1
2010-12-20 16:24:20
false
16,808
How many comments do I have with score greater than 1 ?
How many comments do I have with score greater than 1 ?
WITH score greater than 1 ? -- How many comments do I have WITH score greater than 1 ? select count(score) from comments where userid = ##UserID## and score > 1
2010-12-21 03:02:45
false
16,928
Questions by month per tag
Question count for a particular tag
SELECT datepart(year, p.CreationDate) Year, datepart(month, p.CreationDate) Month, count(*) as questions from Posts p join PostTags pt on pt.PostId = p.Id join Tags t on t.Id = pt.TagId group by datepart(year, p.CreationDate), datepart(month, p.CreationDate) order by datepart(year, p.CreationDate) desc, datepart(month, p.CreationDate) desc
2015-11-16 09:12:50
false
17,071
The best (or the worst) of the best and worst
null
SELECT Score, Id AS [Post Link], AnswerCount FROM Posts WHERE Title LIKE '%worst%' OR Title LIKE '%best%' ORDER BY Score DESC
2010-12-28 02:51:15
false
17,291
Average Question Score by Hour
Find out if time of day when you ask a question may affect the number of votes you receive. Results are skewed by different parts of the world being awake at different times, with each region possibly asking questions of different perceived quality.
SELECT datepart(hour,creationdate) AS hour, count(*) AS posts, avg(CAST(score AS float)) AS "average score" FROM posts GROUP BY datepart(hour,creationdate) ORDER BY hour;
2011-01-01 00:34:21
false
17,304
Average Answer Score by Hour
Find out if time of day when you ask answer question may affect the number of votes you receive. Results are skewed by different parts of the world being awake at different times, with each region possibly posting answers of different perceived quality.
WITH each region possibly posting answers of -- different perceived quality. SELECT datepart(hour,creationdate) AS hour, count(*) AS answers, avg(CAST(score AS float)) AS "average answer score" FROM posts WHERE posttypeid=2 GROUP BY datepart(hour,creationdate) ORDER BY hour;
2011-01-01 02:07:05
false
17,305
Average Comment Score by Hour
Find out if time of day when you make a comment may affect the number of votes you receive. Results are skewed by different parts of the world being awake at different times, with each region possibly posting comments of different perceived quality.
WITH each region possibly posting comments of -- different perceived quality. SELECT datepart(hour,creationdate) AS hour, count(*) AS comments, avg(CAST(score AS float)) AS "average comment score" FROM comments GROUP BY datepart(hour,creationdate) ORDER BY hour;
2011-01-01 02:07:57
false
17,321
My Activity by UTC Hour
What time of day do I post questions and answers most?
SELECT datepart(hour,creationdate) AS hour, count(CASE WHEN posttypeid = 1 THEN 1 END) AS questions, count(CASE WHEN posttypeid = 2 THEN 1 END) AS answers FROM posts WHERE posttypeid IN (1,2) GROUP BY datepart(hour,creationdate) ORDER BY hour
2014-11-11 09:42:11
false
17,349
Are SO users voting less per each Q/A
Shows monthly aggregate averages of scores, page view counts, and answers counts
SELECT PT, Month, Year, count(*)/1000 as kCount, round(avg(cast(Score as numeric)),2) as mScore, round(avg(cast(ViewCount as numeric)),0) as mViewCount, round(avg(cast(AnswerCount as numeric)),2) as mAnswerCount from (SELECT PT = case PostTypeId when 1 then 'Q' when 2 then 'A' else '?' end, Month = datepart(month, CreationDate), Year = datepart(year, CreationDate), * from Posts where CommunityOwnedDate is null ) as t group by PT, Year, Month order by PT, Year, Month
2011-01-01 05:52:28
false
17,717
Top .NET programmers in North Carolina
Rank .NET programmers (anyone who has answered a question relating to .NET) in North Carolina
SELECT DISTINCT Users.Id, Reputation, DisplayName, WebsiteUrl, Location FROM Users INNER JOIN Posts A ON Users.Id = A.OwnerUserId INNER JOIN Posts Q ON Q.Id = A.ParentId INNER JOIN PostTags ON PostTags.PostId = Q.Id INNER JOIN Tags on Tags.Id = PostTags.TagId and Tags.TagName IN ('.net', 'c#', 'asp.net', 'asp.net-mvc') WHERE Location LIKE '%london' OR Location LIKE '%London%' ORDER BY Reputation DESC
2015-05-29 19:57:27
false
17,731
UserId, question count, answer count, and reputation
for graphical analysis
SELECT OwnerUserId, SUM(CNT_Q) AS "Q Count", SUM(CNT_A) AS "A Count", Reputation FROM ( SELECT OwnerUserId, PostTypeId, (SELECT COUNT(PostTypeId) FROM Posts p1 where PostTypeId=1 and p1.Id=p.Id) as CNT_Q, (SELECT COUNT(PostTypeId) FROM Posts p2 where PostTypeId=2 and p2.Id=p.Id) as CNT_A, Reputation FROM Posts p INNER JOIN Users ON p.OwnerUserId=Users.Id WHERE OwnerUserId IS NOT NULL AND OwnerUserId <> -1 ) Q GROUP BY OwnerUserId, Reputation ORDER BY OwnerUserId
2011-01-06 10:30:59
false
17,950
How many questions have I helped to close?
Shows the breakdown of the close reasons you've used in successfully closed questions.
DECLARE @userId int = ##UserId## DECLARE @searchUserId1 nvarchar(25) = '%"Id":' + CAST(@userId AS nvarchar(MAX)) + '}' DECLARE @searchUserId2 nvarchar(25) = '%"Id":' + CAST(@userId AS nvarchar(MAX)) + ',%' SELECT t.Name AS 'Close Reason', SUM(Count) AS Count FROM ( SELECT CAST(PostHistory.Comment AS int) AS CloseReasonId, 1 AS Count FROM PostHistory WHERE (PostHistoryTypeId = 10) AND ((Text LIKE @searchUserId1) OR (Text LIKE @searchUserId2)) ) a, CloseReasonTypes as t WHERE a.CloseReasonId = t.Id GROUP BY a.CloseReasonId, t.Name ORDER BY a.CloseReasonId, SUM(Count) DESC
2015-04-21 03:08:24
false
18,206
Total number of registered users over time
Shows the total number of registered users for every month since site inception.
WITH c AS ( SELECT DATEPART(year, CreationDate) AS Year, DATEPART(month, CreationDate) AS Month, DATEPART(day, CreationDate) AS Day FROM Users ), d AS ( SELECT Year, Month, Day, COUNT(*) OVER(PARTITION BY Year, Month, Day) AS Count FROM c ), e AS ( SELECT Year, Month, Day, Count FROM d GROUP BY Year, Month, Day, Count ), f AS ( SELECT ROW_NUMBER() OVER(ORDER BY Year, Month, Day) AS RowId, Year, Month, Day, Count FROM e ) SELECT Year, Month, Day, (SELECT SUM(Count) FROM f WHERE f.RowId <= q.RowId) AS TotalCount FROM f q ORDER BY Year, Month, Day
2019-12-05 15:27:19
false
18,321
Users with highst number of combined Views
Returns the Users with the highest number of total views for their questions
SELECT Users.Id as [User Link], Sum(ViewCount) as TotalViews FROM Posts INNER JOIN Users ON Users.Id = Posts.OwnerUserId WHERE PostTypeId = 1 GROUP BY Users.Id ORDER BY TotalViews DESC
2011-01-15 14:59:27
false
18,836
Keystrokes per rep point, mod. for user defined rep cutoff
Ranks users with over RepCutoff reputation points by how many characters they needed to type to achieve that reputation (counts title and body characters). Original by shog9.
WITH over RepCutoff reputation points by how many characters they needed to type to achieve that reputation (counts title and body characters). Original by shog9. Select u.Id As [User Link], (sum(coalesce(datalength(p.Body),0)) + sum(coalesce(datalength(p.Title),0))) As keystrokes, u.Reputation, (sum(coalesce(datalength(p.Body),0)) + sum(coalesce(datalength(p.Title),0)))/u.Reputation As rate From users u, posts p Where p.OwnerUserId = u.Id And u.Reputation >=##RepCutoff## Group By u.Id, u.Reputation Order By rate Asc
2011-01-16 22:08:08
false
24,616
Users with highest number of combined Views
Returns the Users with the highest number of total views for their questions
DECLARE @total float SELECT @total = Sum(ViewCount) FROM Posts WHERE PostTypeId = 1 SELECT Users.Id AS [User Link], Sum(ViewCount) AS TotalViews, Count(*) AS NumberOfQuestions, Sum(ViewCount)/Count(*) AS AvgViewsPerQuestion, 100 * Sum(ViewCount) / @total AS PercentOfSite FROM Posts INNER JOIN Users ON Users.Id = Posts.OwnerUserId WHERE PostTypeId = 1 GROUP BY Users.Id ORDER BY TotalViews DESC
2011-01-20 01:08:29
false
24,807
Who has the most copies of one badge?
Determines the ranking of who has the most of one badge, for example Nice Question.
DECLARE @Badge nvarchar(50) = ##BadgeName:string## SELECT UserId as [User Link], Count(*) as Count FROM Badges WHERE Name=@Badge GROUP BY UserId ORDER BY Count DESC
2011-01-21 19:05:27
false
24,862
Food for my blekko unicorn
Web site links of SO users with over NN rep, used to feed my blekko unicorn slashtag (length of 12 filters out most non-links)
DECLARE @MinRep int = ##MinimumReputation## DECLARE @MinLinkLen int = ##MinimumLinkLength## select DisplayName as [User], WebsiteUrl as [Website Link], Reputation as [Reputation] from Users where Reputation > @MinRep and Len(WebsiteUrl) > @MinLinkLen order by Reputation desc
2011-01-22 05:06:10
false
24,898
How much rep would I have if there were no rep cap? [FIXED]
By Joel Coehoorn in this answer: http://meta.stackoverflow.com/questions/42121/is-there-a-script-tool-to-calculate-the-rep-as-if-there-were-no-cap Edited to use a specified User ID.
DECLARE @UserId int = ##UserId## SELECT SUM(Case When VoteTypeID = 1 Then 15 WHEN VoteTypeID=2 THEN 10 WHEN VoteTypeID=3 THEN -2 ELSE 0 END) - Reputation as LostRep, 1.0 - (Reputation * 1.0 / SUM(Case When VoteTypeID = 1 Then 15 WHEN VoteTypeID=2 THEN 10 WHEN VoteTypeID=3 THEN -2 ELSE 0 END)) as [LostRep%] FROM Votes v INNER JOIN Posts p ON p.ID = v.PostID INNER JOIN Users ON Users.ID = p.owneruserid WHERE p.OwnerUserID = @UserID AND p.CommunityOwnedDate IS NULL GROUP BY Reputation
2016-07-14 08:02:59
false
24,936
Posts By User Where Parent Tags Like
Posts by a user with a parent post that has a tag containing a word
DECLARE @UserId int = ##UserId## SELECT d.id as [Post Link], a.body, b.tags, c.viewcount FROM posts a INNER JOIN posts d ON a.parentid=d.id INNER JOIN posts b ON a.parentid=b.id INNER JOIN posts c ON a.parentid=c.id WHERE a.owneruserid=@UserID AND b.tags LIKE '%##TagContains##%' ORDER BY c.viewcount DESC
2015-01-11 08:17:24
false
25,215
Potentially abandoned questions with inactive owners
Returns questions that are old (+6 months), have low views and score, have no upvoted or accept answer and where the user hasn't been active in the last 6 months. Modified from the query build out of this conversation http://chat.stackexchange.com/rooms/118/conversation/querying-for-abandoned-questions
SELECT p.Id AS [Post Link], p.Score, p.Tags as Tags, p.AnswerCount AS Answers, CASE WHEN p.ClosedDate IS NULL THEN NULL ELSE 'Y' END AS Closed, DateDiff(month,p.CreationDate,getdate()) AS MnthsQstAct, u.Id AS [User Link] FROM Posts p LEFT JOIN Users u on p.OwnerUserId = u.Id join PostTags on PostTags.PostId = p.Id join Tags on Tags.Id = PostTags.TagId WHERE p.PostTypeId = 1 AND p.AnswerCount > 1 AND Tags.TagName = 'r' AND p.AcceptedAnswerId IS NULL AND p.CreationDate < dateadd(month,-3,getdate()) AND p.ClosedDate IS NULL ORDER BY p.Score, p.AnswerCount
2014-04-27 19:04:47
false
25,300
Inactive quetsions with score of 1 or higher
This searches for questions that are inactive and have a score of 1 or higher...
WITH score of 1 or higher -- This searches for questions that are inactive and have a score of 1 or higher... SELECT p.Id AS [Post Link], p.LastActivityDate, p.Score FROM dbo.Posts p WHERE p.Score > 3 AND p.CreationDate <= DATEADD(mm, -2, GETDATE()) AND p.AcceptedAnswerId IS NULL AND p.AnswerCount < 2 AND p.ClosedDate IS NULL ORDER BY p.LastActivityDate
2011-01-26 01:14:50
false
25,349
Average votes for mid-level users
Calculate the average upvotes for users with 1000-10000 reputation
DECLARE @MinReputation int = ##MinReputation?1000## -- MinAnswers: Minimum number of answers DECLARE @MinAnswers int = ##MinAnswers?100## select Users.Id as [User Link], max(Users.Reputation) as Reputation, count(1) as Answers, avg(Score) as AnswerScore, avg(Accepted) as AcceptRate from Users, ( select Posts.OwnerUserId as OwnerUserId, sum(case Votes.VoteTypeId when 2 then 1.0 when 3 then -1.0 else 0 end) as Score, sum(case Votes.VoteTypeId when 1 then 1.0 else 0 end) as Accepted from Posts left join Votes on Posts.Id = Votes.PostId where Posts.PostTypeId = 2 group by Posts.Id, Posts.OwnerUserId ) VotesSum where VotesSum.OwnerUserId = Users.Id and Users.Reputation > @MinReputation group by Users.Id having count(1) > @MinAnswers;
2018-10-26 12:37:04
false
25,365
Where have I commented ?
Lists number of comments and score against it for each post.
SELECT postid [Post Link], CreationDate [datetime] FROM Comments WHERE UserId = ##UserId## ORDER BY CreationDate
2015-04-19 16:58:27
false
25,632
Question View count (that are <10k) with average and grouped by user
null
SELECT TOP 100 p.OwnerUserId AS [User Link], sum(ViewCount) as VC, avg(ViewCount) as AVC, COUNT(p.OwnerUserId ) as QC FROM Posts p join Users on p.OwnerUserId = Users.Id where PostTypeId = 1 and ViewCount<10000 and CommunityOwnedDate is null group by p.OwnerUserId HAVING COUNT(p.OwnerUserId ) > 50 order by VC desc
2011-01-29 04:58:22
false
26,337
Old unloved questions possibly eligible for auto-deletion
Questions with score <= 0, low views, no answers
WITH score = 0 and no answers SELECT TOP 200 p.Id AS [Post Link], p.Tags, p.Body FROM Posts p join PostHistory h ON h.PostId = p.Id WHERE p.PostTypeId = 1 AND p.Score = 0 AND isnull(p.AnswerCount,0) = 0 AND p.LastActivityDate < (DateAdd(d, -365, GetDate())) GROUP BY p.Id, p.Tags, p.Body having SUM(CASE WHEN h.PostHistoryTypeId = 14 OR h.PostHistoryTypeId = 10 THEN 1 WHEN h.PostHistoryTypeId = 15 OR h.PostHistoryTypeId = 11 then -1 ELSE 0 END) <= 0 ORDER BY Len(p.Body) ASC
2015-04-03 08:10:38
false
26,493
Questions with accepted answers that have a negative score
null
WITH accepted answers that have a negative score select a.Id as [Post Link], q.Score [Question Score], a.Score [Answer Score] from Posts q join Posts a on a.Id = q.AcceptedAnswerId where q.Score > 0 and a.Score < 0 order by a.Score desc, q.Score desc
2019-07-30 00:39:20
false
26,520
Tags with a high proportion of unanswered questions
with score <= 0, low views, no answers
WITH a high proportion of unanswered questions -- WITH score <= 0, low views, no answers SELECT t.TagName , 100 * CAST( COUNT(p.id) AS FLOAT ) / COUNT(*) AS '% Unanswered' , COUNT( p.id ) AS Unanswered , COUNT( * ) AS Posts FROM Tags t LEFT JOIN PostTags pt ON t.id = pt.TagId LEFT OUTER JOIN Posts p ON pt.PostId = p.id AND p.PostTypeId = 1 AND p.ViewCount < 500 AND ( p.AnswerCount < 1 OR p.AnswerCount IS NULL ) GROUP BY t.TagName HAVING COUNT(*) > 2000 ORDER BY 2 DESC
2011-02-08 05:21:32
false
26,540
Tags with a high proportion of zero-vote accepted answers
null
WITH a high proportion of zero-vote accepted answers SELECT t.TagName , COUNT(*) AS 'Questions' , CAST( COUNT(a.id) AS FLOAT ) / COUNT(*) AS 'Zero-Vote AcceptedPercent' FROM Tags t LEFT JOIN PostTags pt ON t.id = pt.TagId LEFT OUTER JOIN Posts p ON pt.PostId = p.id AND p.AcceptedAnswerId != 0 LEFT JOIN Posts a ON a.Id = p.AcceptedAnswerId AND a.Score = 0 GROUP BY t.TagName HAVING COUNT(*) > 1000 ORDER BY 3 ASC
2011-02-08 05:35:15
false
26,897
Current candidates for proposed Hard Question badge
http://meta.stackoverflow.com/questions/78568/new-badge-hard-question
SELECT Q.Id as [Post Link], Q.Score from Posts Q where Q.Score >= 15 and Q.PostTypeId=1 and Q.ClosedDate is null and Q.AcceptedAnswerId is null and not exists (SELECT A.Id from Posts A where A.Score >= 2 and A.ParentId = Q.Id) order by Q.Score desc
2011-02-09 18:04:55
false
27,067
Answers to Delphi Posts with Accepted Answer and Fav Count>2
Enter Query Description
WITH Accepted Answer and Fav Count>2 -- Enter Query Description select * from Posts where ParentId in ( select Id from Posts where FavoriteCount>2 and AcceptedAnswerId is not null and id in (select PostId from PostTags where TagId in (select Id from Tags where TagName like '%delphi%') ) )
2011-02-10 20:11:47
false
27,179
Gets all down votes for user
SELECT p.Id as [Post Link], SUM(v.PostId) as downVotes FROM Posts p INNER JOIN PostTypes pt ON pt.Id = p.PostTypeId INNER JOIN Votes v ON v.PostId = p.Id INNER JOIN VoteTypes vt ON vt.Id = v.VoteTypeId WHERE p.OwnerUserId = ##UserId## AND vt.Id = 3 AND p.PostTypeId = 1 GROUP BY p.Id
2016-04-09 22:33:05
false
27,276
Where does Col Sharpnel place in downvoting percentage
Where does Col Sharpnel place in downvoting percentage
SELECT sum(case when downvotes=0 then 1 when 1.0*upvotes/nullif(downvotes,0) >= y then 1 end), sum(case when 1.0*upvotes/nullif(downvotes,0) < y then 1 end) from users cross join (SELECT y=1.0*upvotes/downvotes from users where id=285587) x where users.upvotes > 0 and users.reputation > 1000
2011-02-13 15:43:56
false
27,385
Most active users (action every X min)
Users who spend A LOT of time posting, editing, commenting and voting.
DECLARE @dt DateTime = getdate() SELECT TOP 20 UserId AS [User Link], sum(c) as actions FROM ( SELECT UserId, count(*) AS c FROM PostHistory WHERE UserId > 0 GROUP BY UserId UNION ALL SELECT UserId, count(*) AS c FROM Comments WHERE UserId > 0 GROUP BY UserId UNION ALL SELECT UserId, count(*) AS c FROM Votes WHERE UserId > 0 GROUP BY UserId ) a INNER JOIN Users on Id = UserId WHERE dateadd(dd,1,CreationDate) < @dt -- users have to be at least a day old GROUP BY UserId, CreationDate ORDER BY actions
2019-04-11 09:32:00
false
27,525
QUERY: count tags from daterange
TODO: compare from two different dateranges...
SELECT TOP 10 tags.tagname, count(*) AS tagcount from Posts INNER JOIN PostTags ON PostTags.PostId = Posts.id INNER JOIN Tags ON Tags.id = PostTags.TagId where datepart(year, Posts.CreationDate) = 2011 and datepart(month, Posts.CreationDate) = 1 Group by tags.tagname Order by tagcount DESC
2011-02-15 13:27:41
false
27,599
What question should I accept answeres to?
null
DECLARE @UserId int = ##UserId## DECLARE @ScoreWeight float = ##ScoreWeight## DECLARE @AnswerWeight float = ##AnswerWeight## DECLARE @ViewWeight float = ##ViewWeight## DECLARE @AgeWeight float = ##AgeWeight## SELECT q.Id as [Post Link], q.tags, q.Score, q.AnswerCount, q.ViewCount, DATEDIFF(day, q.CreationDate, CURRENT_TIMESTAMP) as age FROM Posts q WHERE q.OwnerUserId = @UserId and q.AcceptedAnswerId is null AND q.PostTypeId = 1 AND q.Score > 0 AND q.AnswerCount > 0 and q.ViewCount > 0 Order by (log(q.Score)*@ScoreWeight+ log(q.AnswerCount)*@AnswerWeight+ log(q.ViewCount)*@ViewWeight+ log(DATEDIFF(day, q.CreationDate, CURRENT_TIMESTAMP))*@AgeWeight) DESC
2011-02-15 21:48:52
false
27,779
Users (with minimum rep) ranked by Median Post Score
Under construction
WITH minimum rep) ranked by Median Post Score SELECT OwnerUserId AS [User Link], AVG(Score) AS MedianScore FROM ( SELECT OwnerUserId, Score, ROW_NUMBER() OVER ( PARTITION BY OwnerUserId ORDER BY Score ASC) AS RowAsc, ROW_NUMBER() OVER ( PARTITION BY OwnerUserId ORDER BY Score DESC) AS RowDesc FROM Posts INNER JOIN Users ON Users.Id = OwnerUserId WHERE Users.Reputation >= ##MinReputation## AND Posts.PostTypeId=2 ) x WHERE RowAsc IN (RowDesc, RowDesc - 1, RowDesc + 1) GROUP BY OwnerUserId ORDER BY MedianScore DESC
2011-02-17 04:42:54
false
27,791
Benford's law on SO - improved
null
SELECT firstDigit, COUNT(*) [Count], convert(decimal(5,2),100.0*COUNT(*)/SUM(COUNT(*)) OVER ()) Percentage, Benford.p Law FROM ( SELECT LEFT(LEN(post.Body),1) as firstDigit FROM Posts as post ) [ ] inner join ( values (1, 30.1), (2, 17.6), (3, 12.5), (4, 9.7), (5, 7.9), (6, 6.7), (7, 5.8), (8, 5.1), (9, 4.6) ) Benford(d,p) on Benford.d = [ ].firstDigit GROUP BY firstDigit, Benford.p Order by firstDigit
2011-02-17 06:02:22
false
28,339
Top Users Reputation per Post
SELECT TOP 100 OwnerUserId as [User Link], SUM(Posts.Score) AS Score, Users.Reputation, COUNT(Posts.Id) AS Posts, CAST(Users.Reputation AS FLOAT)/COUNT(Posts.Id) AS Ratio FROM Posts INNER JOIN Users ON Users.Id = OwnerUserId WHERE Users.Reputation >= 1000 GROUP BY OwnerUserId, Users.Reputation HAVING COUNT(Posts.Id) > 50 ORDER BY Ratio DESC
2011-02-23 09:58:32
false
28,443
How many views your questions received?
Total views, views per day and score per question.
SELECT ViewCount, convert(decimal(10,2), convert(decimal(10,2), ViewCount) / datediff(day, CreationDate, GETUTCDATE())) as [Views per day], Score, Id as [Post Link] FROM Posts WHERE PostTypeId = 1 and OwnerUserId = ##UserId## ORDER BY ViewCount DESC
2011-02-23 23:13:26
false
28,464
What posts have I edited?
Searches for all edits made
DECLARE @UserId int = ##UserId## SELECT PostId AS [Post Link], * FROM PostHistory WHERE UserId = @UserId ORDER BY PostId DESC, Id DESC
2011-02-24 01:20:17
false
28,497
Questions I've answerd and added to Favorites
(that's how I mark answers I liked)
DECLARE @UserId int = ##UserId## select answer.Id as "Post Link" from posts answer inner join votes v on answer.ParentId = v.PostId where answer.OwnerUserId = v.UserId and answer.OwnerUserId = @UserId order by answer.Score desc
2011-02-24 11:09:10
false
28,603
Top 10 users with largest rep
null
SELECT TOP 10 * FROM USERS ORDER BY Reputation DESC
2011-02-24 21:17:45
false
28,702
Editor, Strunk & White, Copy Editor
null
WITH Requirements(Description, Requirement) as ( select 'Editor' , 1 union all select 'Strunk & White', 80 union all select 'Copy Editor' , 500 ) select [User Link] = ##UserId##, [Edits] = c.countRevisions, [Badge] = r.description, [Requirement] = r.Requirement, [To Go] = (select max(ToGo) from (values (r.Requirement - countRevisions), (0)) [ ] (ToGo)) from ( select count(DISTINCT ph.RevisionGUID) as countRevisions from PostHistory ph where ph.UserId = ##UserId## and not exists (select * from Posts p where p.OwnerUserId = ph.UserId and p.Id = ph.PostId) ) c inner loop join Requirements r on 1=1 order by r.Requirement desc
2014-12-10 18:36:02
false
28,715
Best Scoring Post Lengths For User
Score per post for a specific user, grouped by post length (in increments of 500). Enter 1 for Questions, 2 for Answers, 1,2 for both
SELECT FLOOR(LEN(Body)/500) * 500 AS [Post Length], SUM(Score) AS [Total Score], COUNT(Id) AS [Num of Posts], CAST(SUM(Score) AS FLOAT) / COUNT(Id) AS [Score Per Post] FROM Posts WHERE OwnerUserId = ##UserId## AND PostTypeId=2 GROUP BY FLOOR(LEN(Body)/500) * 500 ORDER BY [Post Length] DESC
2011-02-25 10:39:34
false
28,722
My Posts By Post Length
All of my posts sorted by Body length
SELECT Id, Id as [Post Link], LEN(Body) as [Post Length], Score FROM Posts WHERE OwnerUserId = ##UserId## ORDER BY [Post Length] DESC
2011-02-25 10:44:36
false
28,757
Newer users with higher rep
List users that have been members shorter, but have higher rep than this user. The last Entry will be this user, for comparison
DECLARE @UserId int = ##UserId## SELECT u.id as [User Link], cast(datediff(day, u.creationDate, current_timestamp) as nvarchar) + ' Days' as [Member for], u.reputation as [Rep], u.reputation - you.reputation as [Rep more than yours], (u.reputation / datediff(day, u.creationDate, current_timestamp)) as [Avg rep per Day] FROM Users u, Users you WHERE you.Id = @UserId AND u.creationdate >= you.creationdate AND u.reputation >= you.reputation ORDER BY u.creationdate DESC
2011-02-25 22:10:58
false
28,950
Death to "Belongs on SU"
Comments from migrations into Super User about migrating to Super User
SELECT TOP 300 c.PostId AS [Post Link], c.text AS Commented FROM Comments C Where C.Text LIKE '%belongs on su%' Order By c.creationdate desc
2011-02-28 09:03:24
false
28,952
Death to "Belongs on SF"
Comments from migrations into Server Fault about migrating to Server Fault
SELECT TOP 300 c.PostId AS [Post Link], c.text AS Commented FROM Comments C Where C.Text LIKE '%belongs on server fault%' or C.Text LIKE '%belongs on serverfault%' or C.Text LIKE '%belongs on sf%' Order By c.creationdate desc
2011-02-28 09:05:06
false
28,959
Breadcrumbing for Copy Editor with "Belongs on"
Posts ripe for editing out "belongs on" in the answer where they should have been comments or votes to migrate instead
WITH "Belongs on" -- Posts ripe for editing out "belongs on" in the answer where they should have been comments or votes to migrate instead SELECT TOP 200 p.Id AS [Post Link], p.body, LastActivityDate FROM posts p Where p.body LIKE '%belongs on %' and PostTypeId='2' Order By p.LastActivityDate desc
2011-02-28 09:32:12
false
29,151
Everyone's favourite questions for a tag
Non community wiki questions on a particular tag
SELECT FavoriteCount, Posts.Id, Title, 'http://stackoverflow.com/questions/' + cast(Posts.Id as varchar) + '/' as Link FROM Posts JOIN PostTags ON Posts.Id = PostTags.PostId JOIN Tags ON PostTags.TagId = Tags.Id WHERE Posts.PostTypeId = 1 and Tags.TagName = ##Tag:string## and CommunityOwnedDate is null and FavoriteCount >= ##MinFavCount:int## order by FavoriteCount desc
2011-03-04 10:29:06
false
29,348
Short Answers containing "same problem"
Finds extremely short Answer posts that contain the phrase "same problem" These are almost always very low quality non-answers.
SELECT Id as [Post Link], body From Posts Where posttypeid = 2 and len(body) <= 100 and (body like '%can you help%')
2018-03-24 00:25:15
false
29,494
Questions shorter than their title
Finds questions where the body is shorter than the title. These are usually low quality, and we should consider either closing or editing. At the very least, leave a comment asking for clarification.
SELECT Id as [Post Link], body From Posts Where PostTypeId = 1 --Question and len(Body) <= len(Title) ORDER BY Posts.LastActivityDate ASC
2016-12-10 07:37:21
false
29,540
N most recent answers tagged X from user Y
Show the N most recent answers tagged X from user Y. See also http://data.stackexchange.com/stackoverflow/s/1071 [Note: The site's own search facility can do most of this, and probably better; details: http://stackoverflow.com/search]
DECLARE @tagid int SELECT @tagid = Id FROM Tags WHERE TagName = ##JustOneTag:string## SELECT TOP ##Limit## p.Tags as [T], p.Id as [Post Link], p.CreationDate as [Answer Date] FROM Posts p INNER JOIN PostTags pt ON p.ParentId = pt.PostId AND pt.TagId = @tagid WHERE p.PostTypeId = 2 -- 2 = Answer ORDER BY p.CreationDate DESC
2019-06-14 02:00:07
false
29,798
Top 10 users without downvotes
Top 10 users with more than 101 rep, at least 1 upvote and no downvotes.
WITH no downvotes -- These users didn't downvote any posts. EVER. SELECT TOP 10 Id, Reputation, DisplayName, UpVotes FROM USERS WHERE Reputation > 101 AND UpVotes > 0 AND DownVotes = 0 ORDER BY UpVotes DESC;
2011-03-13 16:33:26
false
29,940
Find users under a certain age
Used for finding users who may violate the SE policy on users under 13
SELECT Id as [User Link], DisplayName as Name, Age from Users where -- Usually you would use 13 Age < ##Age## order by Age asc
2011-03-15 22:50:10
false
30,732
Low Voted Answers by Users with high reputation
Shows the stockpiles of low-voted answers that high-rep users have
WITH high reputation -- Shows the stockpiles of low-voted answers that high-rep users have WITH TopUsers AS ( SELECT TOP ##HowManyUsers## Id, Reputation FROM Users ORDER BY Reputation DESC ) SELECT TopUsers.Reputation, [User Link] = TopUsers.Id, Posts.Score, COUNT(*) FROM TopUsers INNER JOIN Posts on Posts.OwnerUserId = TopUsers.Id WHERE Posts.Score ##Operator## ##Score## GROUP BY Posts.Score, TopUsers.Id, TopUsers.Reputation WITH ROLLUP ORDER BY TopUsers.Reputation DESC, Posts.Score DESC
2011-03-25 23:04:31
false
31,018
Questions and Users by time of day
Average score, views, answers, user rep and user age in days, by time of day a question is asked
SELECT DATEPART(hh, p.CreationDate) AS [Post Hour], COUNT(p.Id) as [Questions Asked], AVG(CAST(p.Score as numeric)) AS [Avg Score], AVG(p.ViewCount) AS [Avg Views], AVG(CAST(p.AnswerCount as numeric)) AS [Avg Answers], AVG(CAST(u.Reputation as bigint)) AS [Avg Asker Rep], AVG(CAST(DATEDIFF(dd, u.CreationDate, p.CreationDate) as numeric)) as [Avg User age in Days] FROM Posts p JOIN Users u ON u.Id = p.OwnerUserId WHERE p.PostTypeId = 1 GROUP BY DATEPART(hh, p.CreationDate)
2011-03-29 13:30:35
false
31,056
Answers by Hour of Day
Answers contributed and average score per hour of day
SELECT DATEPART(hh, p.CreationDate) AS [Answer Hour], COUNT(p.Id) as [Questions Answered], AVG(CAST(p.Score as numeric)) AS [Avg Score] FROM Posts p WHERE p.PostTypeId = 2 GROUP BY DATEPART(hh, p.CreationDate)
2011-03-29 14:01:26
false
31,069
Up/down votes for my answers
Up/down vote count for my answers
SELECT SUM(CASE WHEN votes.votetypeid = 2 THEN 1 ELSE 0 END) AS UpVotes, SUM(CASE WHEN votes.votetypeid = 3 THEN 1 ELSE 0 END) AS DownVotes, SUM(CASE WHEN votes.votetypeid IN (2, 3) THEN 1 ELSE 0 END) AS TotalVotes FROM votes INNER JOIN posts ON votes.postid = posts.id WHERE posts.posttypeid = 2 AND posts.owneruserid = ##UserId##
2014-10-17 15:59:02
false
31,215
TOP 500 users from Greece
Lists the top 500 users (ranked by reputation) that are located in Greece according to their profile information. A range of options is used to pinpoint members from Greece based on popular locations used.
SELECT TOP 500 Id, DisplayName, Reputation, WebsiteUrl, Location FROM Users WHERE Location like N'%Thess%' OR Location like N'%Greece%' OR Location like N'%Gr' OR Location like N'%Patra%' OR (Location like N'%Athens%' AND Location NOT like N'%GA%' AND Location NOT like N'%OH%' AND Location NOT like N'%Ga%' AND Location NOT like N'%Oh%') ORDER BY reputation DESC
2011-03-31 14:08:18
false
31,319
Users from the Zwolle, the Netherlands
Lists every user (ranked by reputation) that is located in the Zwolle based on their profile info
SELECT Users.id, Users.Id as [User Link], Reputation, WebsiteUrl, Location FROM Users inner join posthistory ph on ph.userid = Users.id inner join posts on posts.id = ph.postid WHERE Location like N'%Zwolle%' AND tags like '%php%' ORDER BY reputation DESC
2016-07-06 12:27:57
false
31,362
Show top 1000 users by accepted answer percentage
Add a minimum question treshold to filter out people with very few answers Doesn't seem to be fully working yet
WITH very few answers -- Doesn't seem to be fully working yet SELECT TOP 1000 a.OwnerUserId as [User Link], (select Reputation from Users WHERE Id = a.OwnerUserId) as Reputation, ( SELECT Count(*) FROM Posts WHERE OwnerUserId = a.OwnerUserId AND PostTypeId = 2 ) as NumAnswers, (CAST(Count(a.Id) AS float) / (SELECT Count(*) FROM Posts WHERE OwnerUserId = a.OwnerUserId AND PostTypeId = 2) * 100) AS AcceptedPercentage FROM Posts q INNER JOIN Posts a ON q.AcceptedAnswerId = a.Id WHERE a.OwnerUserId = q.OwnerUserId AND a.PostTypeId = 2 GROUP BY a.OwnerUserId HAVING ( SELECT Count(*) FROM Posts WHERE OwnerUserId = a.OwnerUserId AND PostTypeId = 2 ) >= ##MinumumAnswerTreshold## ORDER BY AcceptedPercentage DESC
2011-04-01 13:57:17
false
31,515
"Leet" Users (reputation of precisely 1337)
Return the DisplayName of currently "Leet" users.
SELECT DisplayName from Users where Reputation = 1337;
2011-04-02 01:06:45
false
31,520
"Eleet" Users (reputation of precisely 31337)
Returns DisplayName of currently "Eleet" users.
SELECT DisplayName from Users where Reputation = 31337;
2011-04-02 01:10:06
false
32,286
Recent questions with a score of 5 or more.
List of recent questions on a site with score of 5 or more, capped at 500
WITH a score of 5 or more. -- List of recent questions on a site WITH score of 5 or more, capped at 500 SELECT TOP 500 [Post Link] = Id, Score, CONVERT(VARCHAR(11), CreationDate, 106) AS Date FROM Posts WHERE PostTypeId=1 AND Score>=5 AND ClosedDate IS NULL ORDER BY CreationDate DESC
2011-04-11 21:21:36
false
32,698
UK Users UpVotes Down Votes
null
SELECT ALL Id, DisplayName, Reputation, WebsiteUrl, Location, UpVotes, DownVotes FROM Users WHERE (Location like '%brazil%') ORDER BY reputation DESC
2016-04-09 22:23:06
false
32,822
Search History by revision ID
Enter Query Description
SELECT * from PostHistory where RevisionGUID= '##RevID##'
2011-04-18 10:01:55
false
32,893
Search Users by User Name
null
SELECT * from Users where LOWER(DisplayName) LIKE LOWER('%##UserName##%')
2011-04-18 17:31:28
false
33,044
Number of Android questions and answers on Stack Overflow
Grouped by Month
SELECT count(id) as Questions, sum(AnswerCount) as Answers from Posts where Tags like '%android%'
2013-02-01 09:06:18
false
33,124
List user with Deputy badge and less than 10K reputation.
List user with Deputy badge with no access to moderation tools
WITH Deputy badge and less than 10K reputation. -- List user WITH Deputy badge WITH no access to moderation tools Select userid as [User Link] from Badges inner join users on users.id = Badges.userid where Name like 'Deputy' and reputation < 10000;
2011-04-20 18:01:08
false