Вопросы и ответы для программистов
declare @tag1 nvarchar(25) = '##tag1?python##' declare @tag2 nvarchar(25) = '##tag2?timezone##' declare @date datetime = convert(datetime, '##date?20150401##', 112) SELECT q.Id AS [Post Link], q.Tags, q.LastActivityDate, q.CreationDate, q.AnswerCount, q.Score, q.ViewCount, q.OwnerUserId as [User Link] FROM Posts q join PostTags pt on pt.PostId = q.Id join PostTags pt2 on pt2.PostId = q.Id join Tags t on t.Id = pt.TagId join Tags t2 on t2.Id = pt2.TagId join TagSynonyms ts on ts.TargetTagName = t.TagName join TagSynonyms ts2 on ts2.TargetTagName = t2.TagName WHERE q.PostTypeId = 1 -- question and q.CreationDate < @date and (t.TagName = @tag1 or ts.SourceTagName = @tag1) and (t2.TagName = @tag2 or ts2.SourceTagName = @tag2) GROUP BY q.Id, q.Tags, q.LastActivityDate, q.CreationDate, q.Score, q.ViewCount, q.AnswerCount, q.OwnerUserId ORDER BY q.LastActivityDate DESC, q.CreationDate DESC, q.Score DESC, q.ViewCount DESC