DECLARE @DayLimit int = ##Days?60## DECLARE @DumpTime dat...

0

Please login or register to vote for this query.

(click on this box to dismiss)

TeX - LaTeX

Q&A for users of TeX, LaTeX, ConTeXt, and related typesetting systems

DECLARE @DayLimit int = ##Days?60##
DECLARE @DumpTime datetime
SELECT @DumpTime = MAX(CreationDate) FROM PostHistory

SELECT
  COUNT(*) TotalUsers,
  SUM(IIF(DATEDIFF(DAY, main.LastAccessDate, @DumpTime) < @DayLimit, 1, 0)) ActiveMain,
  SUM(IIF(DATEDIFF(DAY, meta.LastAccessDate, @DumpTime) < @DayLimit, 1, 0)) ActiveMeta,
  -- With close privileges:
  SUM(IIF(main.Reputation >= 3000 AND DATEDIFF(DAY, main.LastAccessDate, @DumpTime) < @DayLimit, 1, 0)) ActiveMain,
  SUM(IIF(main.Reputation >= 3000 AND DATEDIFF(DAY, meta.LastAccessDate, @DumpTime) < @DayLimit, 1, 0)) ActiveMeta
FROM
  [StackExchange.Tex].dbo.Users main
  LEFT OUTER JOIN [StackExchange.Tex.Meta].dbo.Users meta ON meta.Id = main.Id

Enter Parameters

Options:
Switch sites:
loading Hold tight while we fetch your results