Func 1

0

Please login or register to vote for this query.

(click on this box to dismiss)

Emacs

Q&A for those using, extending or developing Emacs

WITH #Questions AS (
  SELECT CAST(CreationDate AS DATE) AS [Date], COUNT(*) AS [Count]
    FROM Posts  
    WHERE CreationDate BETWEEN '2019-11-01' AND '2020-02-29'
      AND PostTypeId = 2 -- A
    GROUP BY CAST(CreationDate AS DATE)
), #Users AS (
  SELECT CAST(CreationDate AS DATE) AS [Date], COUNT(*) AS [Count]
    FROM Users  
    WHERE CreationDate BETWEEN '2019-11-01' AND '2020-02-29'
    GROUP BY CAST(CreationDate AS DATE)
)
SELECT COALESCE(#Questions.Date, #Users.Date) AS 'Date',
  COALESCE(#Users.COUNT, 0) AS 'Number of users created',
  COALESCE(#Questions.COUNT, 0) AS 'Number of questions created',
  CASE WHEN COALESCE(#Questions.Date, #Users.Date)
    BETWEEN '2019-11-01' AND '2020-02-29'
    THEN 0 ELSE NULL END AS 'Winter Bash 2019'
  FROM #Questions
  FULL OUTER JOIN #Users
    ON #Questions.Date = #Users.Date
  ORDER BY COALESCE(#Questions.Date, #Users.Date)

Enter Parameters

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