1

I am forking this query, which essentially outputs the time between the question being asked and the answer being given. However, I am trying to modify the query to only search for . I tried this:

WITH
    Answers AS (
        SELECT *
            FROM Posts as P
              INNER JOIN Tags
              ON Tags.Id = P.TagId
            WHERE PostTypeId = 2 -- Answers
            AND Tags.TagName = 'java'

    )
...

But it clearly does not work. How do I go about doing this?

4

Answers don't have tags, Questions have.

Joining with PostTags on the Posts.ParentId should do the trick for that snippet:

WITH
    Answers AS (
        SELECT *
            FROM Posts as P
              INNER JOIN PostTags pt       -- posttags is the join table
                 ON pt.postid = p.parentid -- join the question
              INNER JOIN Tags
                 ON Tags.Id = pt.TagId     -- join with posttags
            WHERE PostTypeId = 2 -- Answers
            AND Tags.TagName = 'java'

    )
3

The Tags field looks like this: <java><unicode><comments> so you need to use LIKE. Here's how I did it (matching on the questions' tags):

WHERE
    Questions.PostTypeId = 1 -- Questions
    AND Questions.Tags LIKE '%<java>%' -- Line I added
    AND year(Questions.CreationDate) between '2014' AND '2018' 

You must log in to answer this question.

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