I want to get all of my upvoted answers where the question doesn’t have a specific tag.

What query can I write to get that data from SEDE?

For example, I want to get all my upvoted answers to posts that have not been tagged .


You don't need SEDE for this, the regular search is perfectly capable of this.

user:me is:a score:1 -[feature-request]

For me, that search query produces the following results:

enter image description here

Of course, it can be done in SEDE and it's a nice exercise. Here are some pointers:

  • Join the Posts table with itself, the ParentId of the answer is the Id of the question
  • Filter on the OwnerUserId of the answer. You can make this a parameter, so other users can use your query too, and I've written a userscript to fill it automatically.
  • Filter on the Tags of the question, i.e. NOT LIKE '%<feature-request>%'. Bonus points if you make that a parameter too. (Joining with PostTags and Tags is possible as well.)
  • If you mean 'having a positive score' by 'upvoted', you can just filter on the Score of the answer. If you mean posts which received at least one upvote (and an arbitrary number of downvotes), you'd have to join with the Votes table and filter for votes with VoteTypeId equal to 2. Then you'd need a DISTINCT (or a GROUP BY) since you don't want an answer that is upvoted n times to appear n times in the results.
| improve this answer | |
  • Thanks again, It works! I'll accept your answer in a moment... – user569408 Jan 6 at 14:38
  • 1
    ...6-8 moments later... @Jdrupal ;) – Shadow Wizard Wearing Mask Jan 6 at 14:59
  • 1
    @ShadowTheBurningWizard HAHA, thanks for reminding me ;) #busyperson – user569408 Jan 6 at 15:05
  • I tried to create the query with the guidelines you gave, here it is data.stackexchange.com/drupal/query/1175827/…. It seems like it works fine, I just can't figure out how to add multiple tags to the tags input field. – user569408 Jan 7 at 9:59
  • Nice! You'd have to write a separate query, NOT LIKE '%<' + @tag1 + '>%' and NOT LIKE '%<' + @tag2 + '>%'. You could go fancy with STRING_SPLIT and a variable number of tags, but then you'd need joins with PostTags and Tags. – Glorfindel Jan 7 at 10:05
  • Ok, thanks. Thank you for helping me creating my first SEDE query! – user569408 Jan 7 at 10:10
  • You're welcome. For interactive help, you can always check if somebody is available in the SEDE chatroom. – Glorfindel Jan 7 at 10:11
  • Thank's I'll do that in the future! – user569408 Jan 7 at 10:12

You must log in to answer this question.