Sample Tag Query

0

Please login or register to vote for this query.

(click on this box to dismiss)

Stack Overflow

Q&A for professional and enthusiast programmers

SET STATISTICS IO ON 
SET STATISTICS TIME ON 
GO

SELECT TOP 50 Tag1.PostId, LastActivityDate
FROM      (
    SELECT p.Id PostId, LastActivityDate
      FROM Posts p
      JOIN PostTags pt ON p.Id = pt.PostId 
     WHERE pt.TagId = 3
    ) Tag1
LEFT JOIN (
    SELECT p.Id PostId
      FROM Posts p
      JOIN PostTags pt ON p.Id = pt.PostId 
     WHERE pt.TagId = 820
    ) Tag2 ON Tag1.PostId = Tag2.PostId
WHERE     Tag2.PostId IS NULL
ORDER BY  LastActivityDate DESC

SET STATISTICS TIME OFF
SET STATISTICS IO OFF
GO

Enter Parameters

Options:
Switch sites:
loading Hold tight while we fetch your results