Find questions by tags

3

Please login or register to vote for this query.

(click on this box to dismiss)

History of Science and Math

Q&A for people interested in the history and origins of science and mathematics

DECLARE @tag1 AS NVARCHAR(60) = ##Tag1:string? ##;
DECLARE @tag2 AS NVARCHAR(60) = ##Tag2:string? ##;
DECLARE @tag3 AS NVARCHAR(60) = ##Tag3:string? ##;

DECLARE @username AS NVARCHAR(60) = ##DisplayName:string? ##;
DECLARE @userId AS INT = ##UserId:int?-1##;

WITH Questions AS (
  SELECT *
  FROM Posts
  WHERE PostTypeId = 1
    AND (@userId < 0 OR OwnerUserId = @userId)
    AND (@username = '' OR OwnerUserId IN (
        SELECT Id
        FROM Users
        WHERE DisplayName = RTRIM(LTRIM(@username))))
)

SELECT TOP ##Limit:int?100##
  Id [Post Link],
  Tags,
  Score,
  AnswerCount,
  CreationDate,
  ClosedDate
FROM Questions
WHERE
  (@tag1 = '' OR LOWER(Tags) LIKE '%<' + LOWER(RTRIM(LTRIM(@tag1))) + '>%')
  AND (@tag2 = '' OR LOWER(Tags) LIKE '%<' + LOWER(RTRIM(LTRIM(@tag2))) + '>%')
  AND (@tag3 = '' OR LOWER(Tags) LIKE '%<' + LOWER(RTRIM(LTRIM(@tag3))) + '>%')
ORDER BY CreationDate DESC

Enter Parameters

Options:
Switch to meta site
loading Hold tight while we fetch your results