SELECT WeekdaySummary.Time AS Time, WeekdaySummary.Activi...

0

Please login or register to vote for this query.

(click on this box to dismiss)

Stack Overflow

Q&A for programmers

SELECT
  WeekdaySummary.Time AS Time,
  WeekdaySummary.Activity AS WeekdayActivity,
  WeekendSummary.Activity AS WeekendActivity
FROM
(
  SELECT
    Time,
    COUNT(*) Activity
  FROM
  (
    SELECT
      DATEADD(mi, DATEPART(hh, v.CreationDate)*60
        + DATEPART(mi, v.CreationDate)/30*30, 0) AS Time
    FROM SuggestedEditVotes v
    INNER JOIN Users ON Users.Id = v.UserId
    WHERE Users.Reputation >= 3000 AND
          ((DATEPART(dw, v.CreationDate) + @@DATEFIRST) % 7) NOT IN (0, 1)
  ) X
  GROUP BY Time
) as WeekdaySummary
INNER JOIN
(
  SELECT
    Time,
    COUNT(*)*6.0169 Activity -- manually normalized peak weekend (9,342) to peak weekday (56,210)
  FROM
  (
    SELECT
      DATEADD(mi, DATEPART(hh, v.CreationDate)*60
        + DATEPART(mi, v.CreationDate)/30*30, 0) AS Time
    FROM SuggestedEditVotes v
    INNER JOIN Users ON Users.Id = v.UserId
    WHERE Users.Reputation >= 3000 AND
          ((DATEPART(dw, v.CreationDate) + @@DATEFIRST) % 7) IN (0, 1)
  ) X
  GROUP BY Time
) as WeekendSummary
ON WeekdaySummary.Time = WeekendSummary.Time
ORDER BY Time

Enter Parameters

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