5

I've came across this SEDE query by @sam.saffron that provide you (from your favorite tags) interesting questions to answer. I don't really know how SEDE queries work, and I wonder if it is possible to customize this query to search only on a specific tag.

Yet, I just changed SELECT TOP 20 TagId to SELECT TOP 1 TagId from the query to filter only on our best tag (mine is ), but I guess it is possible to pass a specific tag (by its name?).


Other question, is there somewhere a document about "how to write SEDE queries?" for beginners?

1

2 Answers 2

1

I have forked the original query as created by sam.saffron (also known as waffles) and made the adjustments to allow specifying a single tagname without sacrificing the other logic of the query.

This is what my version of the query looks like:

-- Find interesting unanswered questions
-- Looks at unanswered questions in your top 20 tags 
-- or a specific tag
-- sorts them by
-- a combined weight which takes into account: score, askers reputation and how
-- well you do on that particular tag

DECLARE @UserId int = ##UserId##
-- tagname parameter
DECLARE @Tagname nvarchar(35) = '##Tagname?(none)##' -- we don't know null in SEDE

create table #tags (TagId int, [Count] int)

insert #tags 
SELECT TOP 20 
    TagId,
    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
-- handle if the default tagname is used 
-- or handle if an actual tagname is used
AND (@tagname = '(none)' OR Tags.tagname = @tagname)  
GROUP BY TagId
ORDER BY UpVotes DESC


create table #unanswered (Id int primary key)

insert #unanswered 
select q.Id  from Posts q
where (select count(*) from Posts a where a.ParentId = q.Id and a.Score > 0) = 0
and CommunityOwnedDate is null and ClosedDate is null and q.ParentId is null 
and AcceptedAnswerId is null


select top 2000 u.Id as [Post Link], 
(sum(t.[Count]) / 10.0 + us.Reputation / 200.0 + p.Score * 100) as Weight 
from #unanswered u
join Posts p on u.Id = p.Id
join PostTags pt on pt.PostId = u.Id
join #tags t on t.TagId = pt.TagId  
join Users us on us.Id = p.OwnerUserId  
group by u.Id, us.Reputation, p.Score 
order by Weight desc 

Notice that the tagname parameter requires the text (none) to be entered if you want the behavior from the original query. SEDE doesn't allow you to submit a form if not all parameters have a value.

When run today the result for your userid and tag angularjs is:

SEDE result

Keep in mind SEDE is only updated once a week, on Sunday.

If you want to teach yourself how to use SEDE, do try the SEDE Tutorial as offered in a comment by Robert Longson. Feel free to give it a try and provide feedback for the creators.
Beyond that you might find Interesting queries on Data Explorer and Useful Data Queries useful as well as the Database schema documentation for the public data dump and SEDE once you mastered the basics.

1

Not sure if this would be of use, but I previously made this request:

Stack Overflow / Stack Exchange - Advanced Search

In an attempt to expose some of the advanced search functionality that appears on this page.

And even mocked up a JSFiddle to provide a mockup of what it could look like and do. The linked fiddle should work if you tweak the values to tailor your search, but it is simply using the existing search functionality of the site.

enter image description here

For your request, as an example it could generate you a search like so:

angularjs questions created this year, with a score of 3 or more, with zero answers, which isn't closed

You must log in to answer this question.

Not the answer you're looking for? Browse other questions tagged .