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
33,162
Most popular comments for a user
Exactly what it says on the tin. Shows the most popular comments for a given user
SELECT TOP 20 C.PostId AS [Post Link] , C.Score, C.Text FROM Comments C WHERE C.UserId = ##UserId## ORDER BY C.Score DESC
2011-04-21 11:34:43
false
33,180
Tag names that have plural counterparts
null
SELECT S.TagName, S.Count AS [Singular], P.Count AS [Plural] FROM Tags AS S, Tags AS P WHERE P.TagName = S.TagName + 's' AND S.Count > 0 AND P.Count > 0;
2011-04-21 18:18:59
false
33,185
"Not an answer" candidates (upgraded)
This query attempts to find answers that aren't answers within 2 month Detects thanks, same problem, problem also, @
SELECT TOP 500 Id as [Post Link], body FROM Posts WHERE (Body LIKE '%hank%' OR Body LIKE 'same problem' OR Body LIKE 'problem also' OR Body LIKE '@') AND PostTypeId = 2 AND Score < 1 AND len(Body) < 200 -- AND CreationDate >= DATEADD(MONTH, -2, GETDATE()) order by len(body)
2014-08-08 02:59:20
false
33,372
Search Recent Comments by User ID and Text
Search for comments after a given date using a user ID and LIKE string
SELECT PostId as [Post Link], * from Comments where UserId = ##UserId## and CreationDate >= ##DateAsString:string## and text like ##TextInLikeForm:string##
2011-04-25 18:07:19
false
33,522
Missing R tag in R related tag
Find posts without R tag, but with one of closely related tag
WITH out R tag, but WITH one of closely related tag SELECT Id AS [Post Link], Tags, LastActivityDate FROM Posts WHERE Posts.Id IN ( SELECT PostTags.PostId--, max(Tags.TagName) AS TagName FROM PostTags INNER JOIN Tags ON Tags.Id = PostTags.TagId WHERE Tags.TagName in ('ggplot2','lattice','plyr', 'data.frame','sweave','lapply','sapply','r') GROUP BY PostTags.PostId HAVING count(CASE WHEN Tags.TagName='r' THEN 1 END) = 0 -- no R-tag AND count(*)>0 -- but some other ) AND LastActivityDate > '2011-03-01' ORDER BY LastActivityDate DESC ;
2011-04-27 11:50:14
false
33,579
TOP 100 users from Cambridge, UK
Lists the top 100 users (ranked by reputation) that are located Cambridge, UK according to their profile information.
SELECT TOP 100 Id AS [User Link], Reputation, WebsiteUrl, Location FROM Users WHERE (Location like N'%Cambridge%' AND Location NOT like N'%MA%') ORDER BY reputation DESC
2011-04-28 03:39:01
false
33,977
Search accepted answers for YOU
null
SELECT q.Id as [Post Link] FROM Posts q INNER JOIN Posts a ON q.AcceptedAnswerId = a.Id INNER JOIN Users ON Users.Id = q.OwnerUserId WHERE a.OwnerUserId = ##UserId## and q.answercount > 1 ORDER BY q.LastActivityDate DESC
2011-05-02 18:14:41
false
34,077
List bounties won by tag names
null
DECLARE @TagName1 nvarchar(25) = ##Tag1:string## DECLARE @TagName2 nvarchar(25) = ##Tag2:string## DECLARE @TagName3 nvarchar(25) = ##Tag3:string## SELECT p.Id As [Post Link], SUM(v.BountyAmount) As BountyWon, p.Tags AS PostTags FROM Votes v JOIN Posts p ON v.PostId = p.Id JOIN PostTags pt ON pt.PostId = p.Id JOIN Tags t ON t.Id = pt.TagId WHERE (t.TagName = @TagName1 OR t.TagName = @TagName2 OR t.TagName = @TagName3) AND v.BountyAmount > 0 GROUP BY p.Id, p.Tags ORDER BY BountyWon DESC
2012-11-09 16:15:30
false
34,097
Bounty winning answers with low score
See http://data.stackexchange.com/stackoverflow/qe/375/bounties-won
WITH few votes -- See http://data.stackexchange.com/stackoverflow/qe/375/bounties-won SELECT Posts.Id As [Post Link], Posts.Score, v.BountyAmount, Posts.OwnerUserId As [User Link] FROM Votes v INNER JOIN Posts ON v.PostId = Posts.Id WHERE v.VoteTypeId=9 AND Posts.Score < 1 AND v.BountyAmount > 0 ORDER BY Posts.Score
2011-05-03 16:45:18
false
34,111
Finds Posts with images ranked by score
null
SELECT Score AS "Score", Id AS [Post Link] FROM Posts WHERE PostTypeId = 2 AND Body LIKE '%http://i.imgur.com/%' ORDER BY Score
2011-05-03 23:48:39
false
34,515
100 longest posts by user
null
SELECT TOP 100 Id as [Post Link], len(body) AS Length, Score, (Score / CAST(len(body) AS DECIMAL (9,2))) AS Economy FROM posts p WHERE p.OwnerUserId = ##UserId## ORDER BY Economy asc
2013-10-09 03:37:50
false
34,643
Question score by time of day
Questions with at least one answer, grouped by UTC hour.
SELECT DATEPART(ww, CreationDate) AS [Week], Count(*) AS [Total questions], Round(100.0 * Count(CASE WHEN Score < 0 THEN 1 END) / Count(*), 2) AS [% score<0], Round(100.0 * Count(CASE WHEN Score > 0 THEN 1 END) / Count(*), 2) AS [% score>0] --Round(100.0 * Count(CASE WHEN Score < 0 THEN 1 END) / Count(*), 2) AS [% score<0], --Round(100.0 * Count(CASE WHEN Score = 0 THEN 1 END) / Count(*), 1) AS [% score=0], --Round(100.0 * Count(CASE WHEN Score = 1 THEN 1 END) / Count(*), 1) AS [% score=1], --Round(100.0 * Count(CASE WHEN Score > 1 THEN 1 END) / Count(*), 1) AS [% score>1] FROM Posts WHERE PostTypeId = 1 GROUP BY DatePart(ww, CreationDate) ORDER BY DatePart(ww, CreationDate)
2015-02-25 14:07:56
false
34,887
Tags that new users are asking questions in.
Specify at least 2 months because 1 month doesn't show anything because of the data dump.
SELECT t.TagName AS Tag, COUNT(p.OwnerUserId) AS Count FROM Tags t JOIN PostTags pt ON t.Id = pt.TagId JOIN Posts p ON p.Id = pt.PostId JOIN Users u ON u.Id = p.OwnerUserId WHERE {fn NOW()} - u.CreationDate < 30 * ##Months## GROUP BY t.TagName ORDER BY Count DESC
2011-05-10 16:26:16
false
34,888
Tags that new users are answering questions in.
Specify at least 2 months because 1 month doesn't show anything because of the data dump.
SELECT t.TagName AS Tag, COUNT(a.OwnerUserId) AS Count FROM Tags t JOIN PostTags pt ON t.Id = pt.TagId JOIN Posts p ON p.Id = pt.PostId JOIN Users u ON u.Id = p.OwnerUserId JOIN Posts a ON p.Id = a.ParentId WHERE {fn NOW()} - u.CreationDate < 30 * ##Months## GROUP BY t.TagName ORDER BY Count DESC
2011-05-10 16:28:45
false
34,895
New questions that are striking up a lot of views.
Specify at least 2 months because 1 month doesn't show anything because of the data dump.
SELECT t.TagName AS Tag, SUM(p.ViewCount) AS Views FROM Tags t JOIN PostTags pt ON t.Id = pt.TagId JOIN Posts p ON p.Id = pt.PostId WHERE {fn NOW()} - p.CreationDate < 30 * ##Months## GROUP BY t.TagName ORDER BY Views DESC
2011-05-10 16:32:33
false
34,975
Nice Questions without Nice Answers
All non-CW questions scored at least 10 with no non-CW answer that high.
WITH out Nice Answers -- All non-CW questions scored at least 10 WITH no non-CW answer that high. Select question.Id as [Post Link], question.Score, max(answer.Score) as "Top Answer", question.AnswerCount as "Answer Count", question.ViewCount as "View Count" from Posts as question, Posts as answer where answer.CommunityOwnedDate is null and question.CommunityOwnedDate is null and answer.PostTypeId=2 and answer.ParentId = question.Id and question.Score > 10 group by question.Id, question.Score, question.Title, question.AnswerCount, question.ViewCount having max(answer.score) < 10 order by question.score - max(answer.score) desc
2011-05-11 20:01:53
false
34,990
C# and Linq - Hard Questions
Tough questions relating to C# and Linq
SELECT P.Id [Post Link], P.Tags, P.Title, FavoriteCount, ViewCount, AnswerCount, DateDiff(DD, P.CreationDate, GETDATE()) [DaysOutstanding], U.Reputation [Owner Rep], U.Id [User Link] FROM Posts P JOIN Users U ON P.OwnerUserID = U.Id WHERE FavoriteCount > 10 AND ViewCount > 100 AND AcceptedAnswerId IS NULL AND U.Reputation BETWEEN 100 AND 10000 AND (P.Tags LIKE '%c#%' AND P.Tags LIKE '%linq%') ORDER BY P.CreationDate DESC
2011-05-11 21:33:39
false
35,034
Lesser Questions with Good Answers
All non-CW questions scored less than 25 with answers scored over that.
WITH Good Answers -- All non-CW questions scored less than 25 WITH answers scored over that. Select Top 1000 question.Id as [Post Link], question.Score, max(answer.Score) as "Top Answer Score", question.AnswerCount as "Answers", question.ViewCount as "Views" from Posts as question, Posts as answer where answer.CommunityOwnedDate is null and question.CommunityOwnedDate is null and answer.PostTypeId=2 and answer.ParentId = question.Id and question.Score < 25 group by question.Id, question.Score, question.Title, question.AnswerCount, question.ViewCount having max(answer.score) > 25 order by max(answer.score) - question.score desc
2016-10-04 23:06:13
false
35,067
Questions close to be nice, good, great or favorite
Looks for posts with 9, 24, 99 total score Or favorited by 24 people Ordered by most remarquable then by total views
SELECT Users.CreationDate From Users JOIN Badges ON Users.Id = Badges.UserId --JOIN Votes v ON u.Id=v.UserId Where Name Like 'Legendary' --+
2014-10-02 16:47:46
false
35,261
Users who self-answered with a score of < 0
possibly newbies who don't know what they are doing
WITH a score of < 0 -- possibly newbies who don't know what they are doing select q.Id as [Post Link] from Posts q join Users u on q.OwnerUserId = u.Id join Posts a on q.Id = a.ParentId and q.OwnerUserId = a.OwnerUserId where a.Score < 0 and q.AcceptedAnswerId != a.Id and u.Reputation < 15 order by a.CreationDate DESC
2011-05-14 15:46:08
false
35,262
Users who self-answered with a score equal to zero
possibly newbies who don't know what they are doing
WITH a score of < 0 -- possibly newbies who don't know what they are doing select q.Id as [Post Link] from Posts q join Users u on q.OwnerUserId = u.Id join Posts a on q.Id = a.ParentId and q.OwnerUserId = a.OwnerUserId where a.Score = 0 and q.AcceptedAnswerId != a.Id and u.Reputation < 15 order by a.CreationDate DESC
2011-05-14 15:47:06
false
35,295
Find posts by you that contain images
Looks for posts owned by the UserId that contain images by querying for the string "<img" and an optional specific host.
SELECT Id AS [Post Link] FROM Posts WHERE OwnerUserId=##UserId## AND Body LIKE '%img%http:%'
2017-10-02 11:14:41
false
35,596
How Unsung am I? (+verdict)
Zero and non-zero accepted count. Self-accepted answers do not count. Identifies unsung heroes visually as well.
SELECT *, CASE WHEN [Unscored Answers] > 10 AND [Percentage Unscored] >= 25 THEN 'Unsung Hero Indeed !!' ELSE 'Not just yet..' END as [Is User Unsung ?] FROM ( SELECT count(a.Id) as [Accepted Answers], sum(case when a.Score = 0 then 0 else 1 end) as [Scored Answers], sum(case when a.Score = 0 then 1 else 0 end) as [Unscored Answers], sum(CASE WHEN a.Score = 0 then 1 else 0 end)*1000 / count(a.Id) / 10.0 as [Percentage Unscored] 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.postTypeId = 2 ) as UnsungInfo
2011-05-19 15:34:54
false
35,723
Count the number of Deputy with less than 10K reputation
Compute how much user with deputy badge does not have access to moderation tool. Also show the average reputation of those users. Also show the average reputation of those users. Parameter used to filter on the minimum global reputation
WITH less than 10K reputation -- Compute how much user WITH deputy badge does not have access to moderation tool. Also show the average reputation of those users. Also show the average reputation of those users. Select count(*) as Total, avg(reputation) as avergage_reputation from Badges inner join users on users.id = Badges.userid where Name like 'Deputy' and reputation < 10000 and Reputation >= ##Rep##;
2011-05-20 13:27:05
false
35,772
Highest view rate questions (non-Community Wiki). [2]
Highest hitrate non-CW questions, (presumably) what questions are viewed the most per time unit from Google searches.
SELECT TOP 100 p.Id as [Post Link], Score as [Votes], ViewCount as [Views], DATEDIFF(day, p.CreationDate, CURRENT_TIMESTAMP) as age, p.ViewCount / DATEDIFF(day, p.CreationDate, CURRENT_TIMESTAMP) as [View Rate] FROM Posts p WHERE p.ViewCount > 1000 AND --On Stack Overflow there are 100 non-CW post with more than about 28000. p.CommunityOwnedDate is null and -- Field CommunityOwnedDate is absent for non-CW posts. p.ViewCount / DATEDIFF(day, p.CreationDate, CURRENT_TIMESTAMP) > 50 -- ViewCount / age > ORDER BY [View Rate] DESC
2011-05-22 03:37:46
false
36,359
Answers by time of week
Find the number of answers posted at various times of day and days of week.
SELECT [TimeOfDay], sum(case when dow = 1 then 1 else 0 end) Sunday, sum(case when dow = 2 then 1 else 0 end) Monday, sum(case when dow = 3 then 1 else 0 end) Tuesday, sum(case when dow = 4 then 1 else 0 end) Wednesday, sum(case when dow = 5 then 1 else 0 end) Thursday, sum(case when dow = 6 then 1 else 0 end) Friday, sum(case when dow = 7 then 1 else 0 end) Saturday from ( SELECT cast( right('0' + convert(varchar(2), DATEPART(HOUR, CreationDate)), 2) + ':' + right('0' + convert(varchar, DATEPART(MINUTE, CreationDate) / 15 * 15), 2) as datetime ) as [TimeOfDay], convert(int, DATEPART(WEEKDAY, CreationDate)) as dow from Posts p where PostTypeId = 2 ) as X group by [TimeOfDay] order by [TimeOfDay] asc
2012-01-16 14:40:48
false
36,390
Old unanswered questions whose asker is still around
Unanswered questions where the asked has been active in the last 30 days, order with the oldest question first
SELECT Question.Id, Question.Id AS [Post Link], Users.LastAccessDate, Question.AnswerCount FROM Posts AS Question JOIN Users ON Question.OwnerUserId = Users.Id WHERE Question.AcceptedAnswerId IS NULL AND NOT EXISTS (SELECT * FROM Posts AS Answer WHERE Answer.ParentId = Question.Id AND Answer.Score > 0) AND Question.PostTypeId = 1 AND Question.ClosedDate IS NULL AND DateDiff( Day, Users.LastAccessDate, GETDATE() ) < 30 ORDER BY Question.Id ASC
2011-05-30 17:34:08
false
36,577
Score as function of Datalength of Post body
null
WITH cte AS (SELECT Ntile(10) OVER(ORDER BY Body_length ASC) AS 'Bucket', Body_length , id FROM ( SELECT id, Datalength(body) Body_length FROM posts WHERE posttypeid = 2) p) SELECT bucket, AVG(Body_length), SUM(score) FROM posts p INNER JOIN cte ON p.id = cte.id GROUP BY bucket ORDER BY bucket
2011-06-03 00:35:16
false
36,613
Number of edits by a given user
How many edits of each type did I make?
SELECT T.Name, Count(*) FROM PostHistory H INNER JOIN PostHistoryTypes T ON H.PostHistoryTypeId = T.Id GROUP BY T.Name
2017-04-30 16:36:27
false
36,628
Posts with titles of 3 words or less
http://meta.stackoverflow.com/questions/93051/view-all-questions-that-have-titles-of-3-words-or-less
WITH titles of 3 words or less -- http://meta.stackoverflow.com/questions/93051/view-all-questions-that-have-titles-of-3-words-or-less select Id, Title from Posts where PostTypeId = 1 and LEN(Title) - LEN(REPLACE(Title, ' ', '')) <= 2 order by LEN(Title)
2011-06-03 13:55:37
false
36,787
Show tags with non-alphanumeric characters other than a hyphen
Show all tags containing '[^-0-9a-z]'
WITH non-alphanumeric characters other than a hyphen -- Show all tags containing '[^-0-9a-z]' SELECT TagName, Count FROM Tags WHERE TagName LIKE '%[^-0-9a-z]%' ORDER BY Count DESC
2011-06-04 16:51:58
false
36,802
Show posts with tags with non-alphanumeric characters other than a hyphen
Show posts with at least one tag containing '[^-0-9a-z]'
WITH tags WITH non-alphanumeric characters other than a hyphen -- Show posts WITH at least one tag containing '[^-0-9a-z]' SELECT TOP 100 CASE WHEN Len(Tags) >= 2 THEN Replace(Replace( Substring(Tags, 2, Len(Tags) - 2), '><', ' '), 'àé', ' ') ELSE Tags END As [Tags], Count(*) As [Count] FROM Posts WHERE Tags LIKE '%[^-öéàabcdefghijklmnopqrstuvwxyz0-9]%' GROUP BY Tags ORDER BY Count DESC
2011-06-04 17:04:50
false
36,919
Kill 11.04 crap questions with Fire
Unanswered 11.04 questions sorted by score and time
WITH Fire -- Unanswered 11.04 questions sorted by score and time SELECT P.Id AS [Post Link], P.CreationDate, P.Score FROM Posts AS P, PostTags AS PT, Tags AS T WHERE (T.Id = PT.TagId AND P.Id = PT.PostID) AND T.TagName = '11.04' AND AcceptedAnswerID IS NULL -- GROUP BY , P.Id, P.Score ORDER BY P.Score ASC, P.CreationDate DESC
2011-06-06 00:54:31
false
36,934
Orphan questions that were migrated from another site
Questions that were migrated and have no owner
SELECT TOP 1000 p.Id As [Post Link], p.CreationDate As [Date], -- ph.UserId As [User Link], -- always Community -- ph.UserDisplayName As [History user name], -- always null p.OwnerDisplayName As [Current user name], ph.Comment As [Comment] FROM Posts p INNER JOIN PostHistory ph ON ph.PostId = p.Id WHERE ph.PostHistoryTypeId = 17 AND p.PostTypeId = 1 AND p.OwnerUserId IS NULL ORDER BY p.Id DESC
2011-06-06 02:27:00
false
38,557
Get all your posts and comments
This displays all posts and comments on Stack Overflow for a particular user.
SELECT CreationDate, Title, Body, PostTypeId from Posts where OwnerUserId=##User:int##) UNION (SELECT CreationDate, null, text, 1 from comments where UserId=##User:int##)
2014-03-03 21:01:44
false
38,704
Average question score/views by hour
null
SELECT DatePart(mm,CreationDate) Month, DatePart(yyyy,CreationDate) Year, Round(Avg(Cast(Score as float)),2) AvgScore, Avg(ViewCount) AvgViews FROM Posts WHERE PostTypeId = 1 GROUP BY DatePart(mm,CreationDate), DatePart(yyyy,CreationDate) ORDER BY DatePart(yyyy,CreationDate), DatePart(mm,CreationDate)
2012-02-29 21:29:13
false
38,923
Bounty amount with user count before/after 2010-06-18
Code to retrieve the count of bounties and users before and after any user-any bounty change.
WITH user count before/after 2010-06-18 -- Code to retrieve the count of bounties and users before -- and after any user-any bounty change. SELECT 'Before' 'befaf', COUNT(*) bounties, (SELECT COUNT(*) FROM Users WHERE CreationDate <= '2010-06-18') 'Users registered' FROM Votes WHERE CreationDate <= '2010-06-18' AND BountyAmount IS NOT NULL UNION ALL SELECT 'After', COUNT(*), (SELECT COUNT(*) FROM Users WHERE CreationDate > '2010-06-18') FROM Votes WHERE CreationDate > '2010-06-18' AND BountyAmount IS NOT NULL UNION ALL SELECT 'Total', COUNT(*), (SELECT COUNT(*) FROM Users) FROM Votes WHERE BountyAmount IS NOT NULL
2011-06-29 00:06:54
false
38,979
Closed Questions with less than 100 views and greater than -2 score.
null
WITH less than 100 views and greater than -2 score. SELECT q.Id AS [Post Link], q.ViewCount AS Views FROM Posts q WHERE q.ClosedDate < '2011-06-01' AND q.Score > -2 AND q.ViewCount < 100 ORDER BY Views ASC
2011-06-29 05:33:03
false
39,048
Questions with highest rated answers
highest rated non-CW answers to non-CW questions
WITH highest rated answers -- Questions WITH highest non-CW answers SELECT TOP 500 answer.Id as [Post Link], answer.ParentId,question.Title,answer.Score FROM posts AS answer, posts AS question WHERE answer.ParentId = question.Id AND question.CommunityOwnedDate IS NULL AND answer.CommunityOwnedDate IS NULL ORDER BY Score DESC
2018-02-07 22:33:32
false
39,068
Show 10 most viewed posts on SO
null
SELECT top(10) ViewCount, Id AS [Post Link] from Posts order by ViewCount desc
2015-08-04 13:04:25
false
39,198
The 'I don't want any badges' guys
Or the higher conversion rate between badges and reputation
SELECT TOP 1000 u.id [User Link], u.reputation as Reputation, count(1) as Badges, u.reputation/count(1) as ReputationsForABadge from badges b inner join users u on b.userid = u.id where u.reputation > 121 group by u.id, u.reputation order by ReputationsForABadge desc
2013-01-21 03:55:25
false
39,224
Tags that are used together - Three tags edition
This might give some interesting insight in the types of posts on a site..
SELECT * from PostTags where TagId=1;
2015-01-27 16:07:08
false
39,522
Badge data for a user from date to now.
Get's the badges that a user has obtained from a point in time (inclusive) to now.
SELECT b.* from Badges as b where b.UserId = ##UserId## and b.[Date] >= ##AsOf## order by b.Date
2012-07-03 19:38:27
false
39,822
My top 10 Posts with highest score for Comments
My top 10 Posts with highest score for Comments
DECLARE @UserId int = ##UserId## SELECT TOP 10 a.Score, a.PostId as [Post Link] FROM (SELECT *, row_number() over(partition BY PostId ORDER BY Score) cn FROM Comments WHERE UserId = @UserId )a WHERE cn = 1 ORDER BY score DESC
2011-07-09 01:05:48
false
39,838
median comment count on all questions
null
SELECT ( (SELECT MAX(CommentCount) FROM (SELECT TOP 50 PERCENT CommentCount FROM Posts where PostTypeId = 1 ORDER BY CommentCount) AS BottomHalf) + (SELECT MIN(CommentCount) FROM (SELECT TOP 50 PERCENT CommentCount FROM Posts where PostTypeId = 1 ORDER BY CommentCount DESC) AS TopHalf) ) / 2 AS Median
2011-07-09 09:26:23
false
39,889
Response time: distribution in hours until accepted answer
null
SELECT COUNT(*) AS [Count], datediff(Hour, qu.CreationDate, ans.CreationDate) AS Hours from posts qu join posts ans on qu.AcceptedAnswerId = ans.Id GROUP BY datediff(Hour, qu.CreationDate, ans.CreationDate) order by [Hours] ASC
2012-11-21 18:25:42
false
40,297
Number of Android questions and answers on Stack Overflow (weekdays)
Grouped by Month
SELECT convert(varchar(8), CreationDate, 126) as Date, count(id) as Questions, sum(AnswerCount) as Answers from Posts where Tags like '%android%' and ((DATEPART(dw, CreationDate) + @@DATEFIRST) % 7) NOT IN (0, 1) group by convert(varchar(8), CreationDate, 126) order by convert(varchar(8), CreationDate, 126) desc;
2011-07-14 18:04:33
false
40,360
High View Counts with no Images
Questions whos answers don't have any screenshots but have a very high view count
SELECT P.Id AS [Post Link], P.Score, P.ViewCount FROM Posts AS P WHERE P.ClosedDate IS NULL AND P.PostTypeId = 1 AND P.AnswerCount >= 1 AND P.Id NOT IN ( SELECT A.ParentId FROM Posts AS A WHERE A.PostTypeId = 2 AND A.Score >= 2 AND A.Body LIKE '%imgur%' ) ORDER BY P.ViewCount DESC
2011-07-16 01:40:31
false
41,007
Answers with best score, but question has no accepted answer
Find all your unappreciated answers.
WITH best score, but question has no accepted answer -- Find all your unappreciated answers. SELECT a1.id as [Post Link], a1.CreationDate, a1.Score, Scores.maxScore as [Next Best], a1.lastActivityDate, a1.CommentCount FROM Posts a1 INNER JOIN Posts q ON q.ID = a1.ParentID INNER JOIN (SELECT MAX(p.Score) as maxScore,p.ParentID as ID FROM Posts p WHERE p.OwnerUserId<>##UserId## GROUP BY p.ParentId) Scores ON a1.ParentID = Scores.ID WHERE a1.OwnerUserID= ##UserId## AND q.AcceptedAnswerID IS NULL AND Scores.maxScore < a1.Score ORDER BY a1.lastActivityDate DESC
2011-07-21 02:04:59
false
42,432
Questions by Time of Day
Designed to consider whether "night" questions have more visibility than "day" questions
SELECT datepart(hour, Posts.CreationDate) Hour, count(Posts.Id) Questions from Posts where PostTypeid = 1 -- 1 = Question group by datepart(hour, Posts.CreationDate) order by datepart(hour, Posts.CreationDate) -- order by count(posts.id) desc
2015-02-08 22:34:16
false
42,437
Questions by Time of Day and Day of Week
Designed to consider whether "night" questions have more visibility than "day" questions
SELECT ((datepart(weekday, Posts.CreationDate)) + (datepart(hour, Posts.CreationDate))/24.0) as HourOfWeek, count(Posts.Id) Questions from Posts where PostTypeid = 1 -- 1 = Question group by datepart(weekday, Posts.CreationDate), datepart(hour, Posts.CreationDate) order by HourOfWeek asc -- order by count(posts.id) desc
2015-02-08 22:53:22
false
42,438
Answers by Time of Day and Day of Week
Designed to consider whether "night" questions have more visibility than "day" questions
SELECT datename(weekday, Posts.CreationDate) Weekday, datepart(hour, Posts.CreationDate) Hour, count(Posts.Id) Answers from Posts where PostTypeid = 2 -- 2 = answer group by datename(weekday, Posts.CreationDate), datepart(hour, Posts.CreationDate) -- order by datepart(hour, Posts.CreationDate) order by count(posts.id) desc
2011-07-29 07:02:34
false
42,479
Find a user's 30 shortest posts (both questions and answers).
Obtains a user's shortest 30 posts, including both questions *and* answers.
DECLARE @UserId int = ##UserId##; SELECT TOP 30 Id AS [Post Link], Len(Body) AS [Characters], Replace(Replace(Body, '<p>', ' '), '</p>', '') AS [Body], Score As [Total Score] FROM Posts WHERE (OwnerUserID = @UserId) ORDER BY Len(Body) ASC
2011-07-29 17:09:45
false
42,480
Find a user's 30 longest posts (both questions and answers).
Obtains a user's longest 30 posts, including both questions *and* answers.
DECLARE @UserId int = ##UserId##; SELECT TOP 30 Id AS [Post Link], Len(Body) AS [Characters], Replace(Replace(Body, '<p>', ' '), '</p>', '') AS [Body], Score As [Total Score] FROM Posts WHERE (OwnerUserID = @UserId) ORDER BY Len(Body) DESC
2011-07-29 17:10:08
false
42,594
Monthly growth of given tag
DECLARE @tag nvarchar(25) = ##tag:string## select datepart(year, Posts.CreationDate), datepart(month, Posts.CreationDate) , count(tags.tagname) from Posts inner join PostTags on PostTags.PostId = Posts.id inner join tags on tags.id = PostTags.TagId where tags.tagname = @tag group by datepart(month, Posts.CreationDate), datepart(year, Posts.CreationDate)
2011-07-30 15:32:47
false
43,014
Tags with Worst Acceptance Rates
All tags sorted to show those the lowest % of accepted answers. Only considers open questions. Includes extra info for proportion of questions that are answered and average number of answers.
WITH Worst Acceptance Rates -- All tags sorted to show those the lowest % of accepted answers. -- Only considers open questions. SELECT T.TagName, COUNT( P.Id ) AS Posts, COUNT( P.AcceptedAnswerId ) AS WITHAccepted, ROUND( CAST( COUNT( P.AcceptedAnswerId ) AS FLOAT) / COUNT( P.Id ) , 3 ) AS AcceptanceRate, COUNT( P.AnswerCount ) AS WITHAnswers, ROUND( AVG( CAST( P.AnswerCount AS FLOAT ) ) , 3 ) AS AveNumOfAnswers, ROUND( CAST( COUNT( P.AnswerCount ) AS FLOAT ) / COUNT( P.Id ) , 3 ) AS AnsweredRate FROM Tags T JOIN PostTags PT ON T.Id = PT.TagId JOIN Posts P ON P.Id = PT.PostId WHERE P.ClosedDate IS NULL GROUP BY T.TagName ORDER BY AcceptanceRate ASC
2013-06-02 12:59:59
false
43,336
Who Brings in the Crowds?
Users sorted by total number of views of their questions per day (with a 30-day softener to keep hot new posts from skewing the results).
WITH a slight softener to keep very new posts from skewing the results). SELECT q.OwnerUserId as [User Link], count(q.Id) as Questions, sum(q.ViewCount/(30+datediff(day, q.CreationDate, datadumptime ))) AS [Question Views per Day] FROM posts AS q, (select max(LastAccessDate) as datadumptime from Users) tmp WHERE q.CommunityOwnedDate is null AND q.OwnerUserId is NOT null AND q.PostTypeId=1 and q.OwnerUserId = ##UserId## GROUP BY q.OwnerUserId
2014-02-03 18:27:32
false
43,481
Tag statistics per year, month
My gut feeling says there is smt happening with question of python, and then i tried to find some proof to my gut feeling.
SELECT (cast(datepart(year, p.CreationDate) as float) + (datepart(month, p.CreationDate) / 12.0)), count(*) as questions, count(p.ClosedDate) as closed_questions, sum(p.Score*1.0) as total_score, sum(p.AnswerCount*1.0) as total_answers, sum(p.CommentCount*1.0) as total_comment, sum(p.FavoriteCount * 1.0) as total_favorite from Posts p join Posts p1 on p.Id = p1.ParentId join PostTags pt on pt.PostId = p.Id join Tags t on t.Id = pt.TagId where t.TagName = ##Tag:string## and p.PostTypeId = 1 group by (cast(datepart(year, p.CreationDate) as float) + (datepart(month, p.CreationDate) / 12.0))
2016-03-18 21:26:38
false
44,592
Which tags have the most closed questions?
null
SELECT Tags.TagName, Count(*) AS ClosedCount from Tags inner join PostTags on PostTags.TagId = Tags.id inner join Posts on PostTags.PostId = Posts.Id where Posts.ClosedDate is not null group by Tags.TagName order by ClosedCount desc
2011-08-19 13:10:43
false
44,641
Find tags that only differ by hyphenation
null
SELECT CASE WHEN a.Count >= b.Count THEN a.TagName ELSE b.TagName END AS First, CASE WHEN a.Count < b.Count THEN a.TagName ELSE b.TagName END AS Second FROM Tags AS a, Tags AS b WHERE a.Id < b.Id AND REPLACE(a.TagName, '-', '') = REPLACE(b.TagName, '-', '');
2014-10-30 22:18:50
false
44,661
Score as function of Datalength of Post body weighted by number of questions
null
WITH cte AS ( SELECT Ntile(10) OVER(ORDER BY Body_length ASC) * 10 AS 'Percentile', Body_length, id FROM ( SELECT id, Datalength(body) Body_length FROM posts WHERE posttypeid = 2 ) p) SELECT Percentile, AVG(Body_length) AS 'Average Post Length', SUM(score) / COUNT(score) AS 'Average Votes per Post' FROM posts p INNER JOIN cte ON p.id = cte.id GROUP BY Percentile ORDER BY Percentile
2011-08-20 00:56:32
false
44,697
Select Short Answers With a Score Equal or more than x
DECLARE @score int = ##Score## Select Id as [Post Link], body From Posts Where posttypeid = 2 and len(body) <= 100 and Score >= @score
2011-08-20 02:17:38
false
44,776
The longest post that don't contain awesome newlines.
For some people, the enter key seems to be broken...
SELECT TOP 100 ph1.PostId AS [Post Link], LEN(ph1.Text) FROM PostHistory ph1 WHERE REPLACE(REPLACE(ph1.Text, CHAR(13), 'AWESOMENEWLINE'), CHAR(10), 'AWESOMENEWLINE') NOT LIKE '%AWESOMENEWLINE%' AND NOT EXISTS (SELECT ph2.Id FROM PostHistory ph2 WHERE ph2.PostId = ph1.PostId AND ph2.CreationDate > ph1.CreationDate) ORDER BY LEN(Text) DESC
2011-08-20 16:12:16
false
44,968
All answers containing "same problem"
null
SELECT *,Id as [Post Link] FROM Posts WHERE Body LIKE '%same problem%' AND Score < 0
2011-08-23 23:24:33
false
44,982
Show all answers with lenght < 100 with link to other SO answer
null
SELECT Score, Body, Id as [Post Link] FROM Posts WHERE PostTypeId = 2 AND Body LIKE '%stackoverflow.com/questions/%' AND LEN(Body) < 100 ORDER BY Score ASC
2011-08-23 23:59:36
false
44,987
Find questions with "[in,using] <TAG>" at the end of their title
Returns all questions that end with "in <TAG>" or "using <TAG>" where the question is already tagged with <TAG>
WITH "in <TAG>" at the end of their title -- Returns all questions that end WITH "in <TAG>" where the question is already tagged WITH <TAG> Select p.id as [Post Link], p.tags as Tags From Posts p Where p.Title Like '%[in,using] ##Tag##' And p.Tags Like '%<' + LOWER('##Tag##') + '>%'
2011-08-24 01:16:44
false
45,152
Downvoted answers of answerers own questions
null
SELECT a.Id As [Post Link], a.Score As [Score], a.CreationDate as [Date] FROM Posts a INNER JOIN Posts q on a.ParentID = q.Id and a.OwnerUserID = q.OwnerUserId WHERE a.PostTypeId = 2 AND a.Score < 0 and a.Id != q.AcceptedAnswerId order by a.Score, a.CreationDate
2011-08-26 00:42:31
false
45,220
Number of active users with >= 1 post in last 30 days
Enter Query Description
SELECT Count(*) FROM Users WHERE Reputation > 500 AND --DATEDIFF(day,CreationDate, GETDATE()) > 30 AND DATEDIFF(day,LastAccessDate, GETDATE()) > 365 /*(SELECT Count(*) FROM Posts WHERE (Posts.OwnerUserId = Users.Id) AND (DATEDIFF(day, CreationDate, GETDATE()) < 365) ) > 1*/
2017-08-11 17:21:11
false
45,726
What percentage of my answers are accepted?
Returns the total number of answers, the number of accepted answers, and what percentage of answers are accepted.
SELECT Count(a.Id) AS [Total Answers], Sum(CASE q.AcceptedAnswerId WHEN a.Id THEN 1 ELSE 0 END) AS [Accepted Answers], Round(Sum(CASE q.AcceptedAnswerId WHEN a.Id THEN 1 ELSE 0 END) * 100.0 / Count(a.Id), 1) AS [Percentage Accepted] FROM Posts AS a JOIN Posts AS q ON a.ParentId = q.Id WHERE a.OwnerUserId = 11742502 AND q.postTypeId = 1 AND a.postTypeId = 2
2019-11-01 18:05:32
false
45,843
Find identical titles (no closed questions, same owner)
We also show the creation date of the posts.
SELECT a.Id AS [Post Link], a.CreationDate AS "First Date", b.Id AS [Post Link], b.CreationDate AS "Second Date" FROM Posts AS a JOIN Posts AS b ON a.Title = b.Title and a.OwnerUserId = b.OwnerUserId WHERE a.Id < b.Id and a.ClosedDate IS NULL and b.ClosedDate IS NULL;
2011-08-31 23:01:01
false
45,846
Find identical titles (no closed questions, different owner)
We also show the creation date of the posts.
SELECT a.Id AS [Post Link], a.CreationDate AS "First Date", b.Id AS [Post Link], b.CreationDate AS "Second Date" FROM Posts AS a JOIN Posts AS b ON a.Title = b.Title WHERE a.Id < b.Id and a.OwnerUserId != b.OwnerUserId and a.ClosedDate IS NULL and b.ClosedDate IS NULL;
2011-08-31 23:07:11
false
45,901
Find identical titles in a given tag (Trilogy version)
We exclude closed questions, and also show the creation date of the posts. This works only in the trilogy sites (SO, SU, SF, MSO) and some SE 2.0 sites (mathematics, gis, webapps, stats, stackapps, gamedev, webmasters), not in most others of SE 2.0. Use http://data.stackexchange.com/ubuntu/s/1809 there. (Replace ubuntu with your site name.)
DECLARE @tag nvarchar(25) = ##tag:string##; DECLARE @tagpattern nvarchar(25) = '%<' + LOWER(@tag) + '>%'; SELECT a.Id AS [Post Link], a.CreationDate AS "First Date", b.Id AS [Post Link], b.CreationDate AS "Second Date" FROM Posts AS a JOIN Posts AS b ON a.Title = b.Title WHERE a.Id < b.Id and (a.Tags like @tagpattern or b.Tags like @tagpattern) and a.ClosedDate IS NULL and b.ClosedDate IS NULL;
2011-09-01 03:49:38
false
46,080
Something to Flag "Not an answer" in the body of an answer
Enter Query Description
SELECT id [Post Link] from posts where body like '% Edit: %'
2016-02-09 07:13:11
false
46,322
Find identical titles (no closed questions) by the same user
We also show the creation date of the posts.
SELECT a.Id AS [Post Link], a.CreationDate AS "First Date", b.Id AS [Post Link], b.CreationDate AS "Second Date" FROM Posts AS a JOIN Posts AS b ON a.Title = b.Title WHERE a.Id < b.Id and a.ClosedDate IS NULL and b.ClosedDate IS NULL and a.OwnerUserId = b.OwnerUserId;
2011-09-04 17:02:01
false
46,349
My Tags ordered by frequency
Tags of my answers, ordered by frequency
DECLARE @MyUserId int = ##MyUserId##; -- 176569; select count(distinct myAnswer.ParentId) as cnt, tag.Id tagID, tag.TagName tagName from Posts as myAnswer, PostTags as a2t, Tags as tag where a2t.PostId = myAnswer.ParentId and a2t.TagId = tag.Id and myAnswer.ownerUserId = @MyUserId and myAnswer.postTypeId = 2 group by tag.Id, tag.TagName order by cnt desc
2011-09-04 19:24:58
false
46,557
Newest questions with score > 10 and "best" in their title
null
SELECT Top 100 Id [Post Link], Score, CreationDate, ClosedDate FROM Posts WHERE PostTypeId = 1 AND Score > 10 AND (Title LIKE '%best%' OR Title LIKE '%Best%') ORDER BY CreationDate DESC, Score DESC -- Enter Query Description
2011-09-07 08:08:35
false
46,854
Users with highest reputation/# answers ratio
null
SELECT TOP 100 Id [User Link], Reputation, count Answers, Reputation / count ratio FROM Users u INNER JOIN (SELECT OwnerUserId, COUNT(*) count FROM Posts GROUP BY OwnerUserId) a ON u.Id = a.OwnerUserId WHERE Reputation > ##MinRep## ORDER BY ratio DESC; -- Enter Query Description
2011-09-09 09:59:14
false
46,878
Number of Unanswered post with single tag, sorted by tag
null
SELECT Tags, COUNT(*) FROM Posts WHERE Tags NOT LIKE '%><%' AND PostTypeId = 1 AND ClosedDate IS NULL AND AnswerCount = 0 GROUP BY Tags ORDER BY COUNT(*) DESC, Tags
2011-09-09 16:28:02
false
46,926
Vote Breakdown on a user's answers/questions.
VoteType: 1 = Accept; 2 = Upvote; 3 = Downvote PostType: 1 = Question; 2 = Answer
DECLARE @UserId int = ##UserId## DECLARE @VoteType int = ##VoteType## DECLARE @PostType int = ##PostType## select COUNT(*) from Votes v join Posts p on p.Id = v.PostId and VoteTypeId = @VoteType and PostTypeId = @PostType and OwnerUserId = @UserId
2011-09-09 22:14:07
false
47,309
"Best" posts prior to 2010
All questions that start with the word "Best" and were asked before 2010. "Best way" is excluded from the resulsts.
WITH the word "Best" and were asked before 2010. -- "Best way" is excluded from the resulsts. select CreationDate, Id as [Post Link], Body, Score from Posts where upper(Title) like 'BEST%' and upper(Title) not like 'BEST WAY%' and ClosedDate is null and cast(CreationDate as DATE) < cast('2010-01-01 00:00:00.000' as DATE) order by Score desc
2011-09-15 02:45:56
false
47,316
How many edits until Copy Editor?
Shows a user's total edits so far, how many edits until the "Strunk and White" badge, and how many edits until the "Copy Editor" badge.
DECLARE @USER int = ##UserId##; SELECT COUNT(0) AS 'Number of Edits', 100 - COUNT(0) AS 'Edits until "Strunk and White"', 600 - COUNT(0) AS 'Edits until "Copy Editor"' FROM PostHistory WHERE UserId = @User AND PostHistoryTypeId >= 4 AND PostHistoryTypeId <= 6 AND (SELECT OwnerUserId FROM Posts WHERE Id = PostId) <> @User ;
2011-09-15 07:48:38
false
47,326
Copy Editor and Strunk & White
null
SELECT COUNT(distinct PostId) from PostHistory ph where PostHistoryTypeId in (4,5) and PostId not in (SELECT p.Id from Posts p where p.OwnerUserId = ph.UserId) and UserId = 572644
2011-09-15 10:53:12
false
47,367
Proportion of users who've asked no questions
Counts the number of users with Rep>=1000 who've asked no questions, and the total number of users with Rep>=1000.
SELECT (SELECT count(u.DisplayName) from Users u where u.Reputation >= 1000) as [significant users], (SELECT count(u.DisplayName) from Users u where u.Id not in (SELECT distinct OwnerUserId from Posts where PostTypeId = 1 and OwnerUserId != '') and u.Reputation >= 94000) as [with no questions] ;
2015-08-02 18:22:45
false
47,443
You're probably doing it wrong (Something to flag)
Questions with Multiple Answers by the OP
SELECT a.ParentId [Post Link], a.owneruserid, u.DisplayName, Count(a.id) FROM posts a INNER JOIN posts q on a.parentid = q.id and q.owneruserid = a.owneruserid inner join users u on q.owneruserid = u.id WHERE a.postTypeid = 2 GROUP by a.Parentid, a.owneruserid, u.DisplayName, q.creationdate Having count(a.id) > 2 order by count(a.id)desc
2011-09-16 01:15:39
false
47,481
BURN WITH FIRE ALL STUPID UNICORN COMMENTS
They are just stupid noise.
SELECT PostID as [Post Link], Text FROM Comments WHERE Text LIKE '%unicorn%'
2011-09-16 19:15:31
false
47,559
Average Accepted Answer Score by Content Length
Investigating the effects of tl;dr
SELECT (len(a.body)/##ChunkSize:int##) * ##ChunkSize## AS size, avg(CAST(a.score AS float)) AS "average answer score", count(*) AS answers FROM Posts q INNER JOIN Posts a ON a.Id = q.AcceptedAnswerId WHERE a.posttypeid=2 GROUP BY len(a.body)/##ChunkSize## ORDER BY size;
2011-09-17 22:01:41
false
47,659
Lowest voted and highest voted
Lowest voted question and answer and highest voted
DECLARE @lowestq int, @highestq int, @lowesta int, @highesta int select @lowestq = min(score), @highestq = max(score) from ( select score, count(*) cnt from posts where posttypeid in (1) group by score ) X select @lowesta = min(score), @highesta = max(score) from ( select score, count(*) cnt from posts where posttypeid in (2) group by score ) X select PT.name, P.id, P.score, P.title, P.parentid from posts P inner join posttypes PT on P.posttypeid = PT.id where ( ( posttypeid = 1 and score in (@lowestq, @highestq) ) or ( posttypeid = 2 and score in (@lowesta, @highesta) ) )
2011-09-19 12:02:26
false
47,910
edits 4 badges - Matthew version
null
DECLARE @userid int = ##user## SELECT COUNT(*) AS Edits4Badges FROM ( SELECT CAST(CreationDate AS SMALLDATETIME) AS foo, PostID FROM PostHistory ph WHERE PostHistoryTypeId IN (4,5) AND PostId NOT IN ( SELECT p.Id FROM Posts p WHERE p.OwnerUserId = ph.UserId ) AND UserID = @userid GROUP BY CAST(CreationDate AS SMALLDATETIME), PostID ) AS bar
2011-09-22 03:31:10
false
47,931
Answers by me that contain code.
This query produces a list of your answers where the answer contains one or more "code " blocks.
DECLARE @UserId int = ##UserId## SELECT Id AS [Post Link], Score, ViewCount FROM Posts WHERE OwnerUserID = @UserID ORDER BY ViewCount
2016-11-01 16:58:15
false
48,029
Rep Breakdown of unaccepted answer
null
SELECT CAST((reputation/10)*10 AS VARCHAR) + ' - ' + CAST((reputation/10)*10+9 AS VARCHAR) AS RepRange, COUNT(*) AS Count from users GROUP BY reputation/10 ORDER BY reputation/10
2012-12-16 19:10:40
false
48,036
People with Jesus in their about me section
Yeah, what the name says
WITH Jesus in their about me section -- Yeah, what the name says select Id as [User Link], location, reputation from users where aboutme like '%jesus%' or aboutme like '%Jesus%' order by reputation desc
2011-09-24 10:39:07
false
48,077
Posts with "question" in the title
null
WITH "question" in the title SELECT Title FROM Posts WHERE PostTypeId = 1 AND lower(Title) like ('%question%') AND lower(Title) not like ('%interview%')
2011-09-25 00:57:33
false
48,728
Questions per tag last 6 months
null
SELECT tagname, COUNT(p.id) k FROM Posts p INNER JOIN PostTags pt ON p.iD = pt.PostId INNER JOIN Tags t ON pt.TagID = t.Id WHERE t.TagName = 'ipfs' and p.PostTypeId = 1 and p.creationDate > DATEADD(Month, -6, DATEADD(dd, DATEDIFF(dd, 0, getdate()), 0) ) GROUP BY tagName
2019-08-08 09:35:41
false
49,109
Suggested edits on my stuff
null
SELECT OwnerUserId, count(Id) from SuggestedEdits where OwnerUserId in (100297,190597,2225682,771848,908494,104349,846892,748858,20862,2141635,487339,1427416,1903116,4279 ,3001761,367273,2555451,279627,95810,1252759,505154,704848,7432,541038,2357112,790387,174728,795990,2073595,166749 ) group by OwnerUserId
2020-03-17 11:40:57
false
49,938
Show my answers to R tag
Show my answers to R tag
SELECT a.Score, a.Body, q.Tags, q.Title from Posts q inner join Posts a on q.Id = a.ParentId and a.postTypeId = 2 and q.postTypeId = 1 /*join PostTags on q.Id = PostTags.PostId join Tags on Tags.Id = PostTags.TagId and ... */ where a.CommunityOwnedDate is null and a.OwnerUserId = ##UserId## and q.Tags like '%<r>%' order by a.Score desc
2011-10-14 15:00:54
false
49,988
String search in a tag
Search for questions and answers containing a specific string with a given tag.
WITH a given tag. SELECT Id as [Post Link], OwnerUserId As [User Link], CreationDate As [Date] FROM Posts p WHERE (p.PostTypeId = 1 AND (p.Body LIKE '%##Pattern##%' OR p.Title LIKE '%##Pattern##%') AND (p.Tags LIKE '%<##Tag##>%' OR p.Tags LIKE '%é##Tag##à%')) OR (p.PostTypeId = 2 AND (SELECT Count(*) FROM Posts q WHERE q.Id = p.ParentId AND (q.Tags LIKE '%<##Tag##>%' OR p.Tags LIKE '%é##Tag##à%')) <> 0 AND p.Body LIKE '%##Pattern##%') ORDER BY Id ASC
2011-10-16 01:07:21
false
50,037
Top 100 users in a given tag (TeX version)
This query fetches the top 100 users on a given tag name. The original query is available here: data.stackexchange.com/stackoverflow/s/1791
DECLARE @TagName nvarchar(25) = ##Tag:string## SELECT TOP 1000 u.Id as [User Link], COUNT(*) AS UpVotes FROM Tags t with (nolock) INNER JOIN PostTags pt with (nolock)ON pt.TagId = t.id INNER JOIN Posts p with (nolock) ON p.ParentId = pt.PostId INNER JOIN Votes v with (nolock) ON v.PostId = p.Id and v.VoteTypeId = 2 inner join Users u with (nolock) on u.Id = p.OwnerUserId WHERE p.CommunityOwnedDate IS NULL and t.TagName = @TagName GROUP BY u.Id ORDER BY UpVotes DESC
2015-07-24 20:53:44
false
50,093
Questions I have answered that contain some text but excluding questions with a tag
For looking for questions you've answered that may need a tag added
DECLARE @user int = ##user:int## DECLARE @excluded_tag nvarchar(25) = ##excludedtag:string## DECLARE @text nvarchar(25) = ##text:string## SELECT q.Id As [Post Link], a.Score As [Answer Score] FROM Posts q, Posts a WHERE q.Tags NOT LIKE '%<' + @excluded_tag + '>%' AND (q.Body LIKE '%' + @text + '%' OR q.Title LIKE '%' + @text + '%') AND a.ParentId = q.Id AND a.OwnerUserId = @user ORDER BY [Answer Score] DESC
2011-10-18 04:16:39
false
50,291
Total of questions asked per month
This query fetches the amount of questions asked per month, organized by month and year. Modified to sort by year first.
SELECT datepart(year,CreationDate) as year, COUNT(id) as total FROM Posts WHERE PostTypeId = 1 AND tags LIKE '%<r>%' GROUP BY datepart(year,CreationDate) ORDER BY datepart(year,CreationDate)
2019-12-04 21:32:49
false
50,371
How many users have I helped?
A count of the unique users who have accepted one of a user's answers. (Excludes the user accepting their own answers)
SELECT COUNT(a.Id) as [Total Answers], COUNT(DISTINCT q.OwnerUserId) as [Unique Users], SUM(case when q.AcceptedAnswerId = a.Id then 1 else 0 end) as [Accepted Answers], COUNT(DISTINCT case when q.AcceptedAnswerId = a.Id then q.OwnerUserId end) as [Unique Users Who Accepted], SUM(q.ViewCount) as [Estimate views of answers], SUM(case when q.AcceptedAnswerId = a.Id then q.ViewCount else 0 end) as [Estimate views of accepted answers] from Posts q inner join Posts a on a.ParentId = q.Id where a.OwnerUserId = ##UserId## and q.OwnerUserId != ##UserId##
2011-10-23 15:14:35
false