DECLARE @MOM datetime = '2020-06-01' DECLARE @YTD datetim...

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

DECLARE @MOM datetime = '2020-06-01'
DECLARE @YTD datetime = '2020-01-01'

DECLARE @UserId int = 158668

SELECT COUNT(DISTINCT A.Id) AS MOM
FROM Posts AS A
  INNER JOIN PostTags ON A.ParentId = PostTags.PostId
  INNER JOIN Tags ON PostTags.TagId = Tags.id
WHERE
  A.OwnerUserId = @UserId
  AND (TagName LIKE 'amazon%' OR TagName LIKE 'aws%')
  AND A.CreationDate >= @MOM;

SELECT COUNT(DISTINCT A.Id) AS YTD
FROM Posts AS A
  INNER JOIN PostTags ON A.ParentId = PostTags.PostId
  INNER JOIN Tags ON PostTags.TagId = Tags.id
WHERE
  A.OwnerUserId = @UserId
  AND (TagName LIKE 'amazon%' OR TagName LIKE 'aws%')
  AND A.CreationDate >= @YTD;

Enter Parameters

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