Q&A for those who study, teach, research and apply economics and econometrics
DECLARE @tag1 AS NVARCHAR(60) = ##Tag1:string? ##; DECLARE @tag2 AS NVARCHAR(60) = ##Tag2: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 10000 Id [Post Link], Title, Body, Tags, Score, AnswerCount, CreationDate FROM Questions WHERE (@tag1 = '' OR LOWER(Tags) LIKE '%<' + LOWER(RTRIM(LTRIM(@tag1))) + '>%') OR (@tag2 = '' OR LOWER(Tags) LIKE '%<' + LOWER(RTRIM(LTRIM(@tag2))) + '>%') ORDER BY CreationDate DESC