SQL for Non-Programmers -- Homework Practice

0

Please login or register to vote for this query.

(click on this box to dismiss)

スタック・オーバーフローMeta

プログラマーと熱狂的なプログラマーのためのサイトに関する質問と回答

WITH ActionHistory AS 
(
  SELECT 'Posting' Type, p.CreationDate, p.OwnerUserId UserId
  FROM Posts p
  WHERE PostTypeId IN (1,2)
  UNION ALL
  SELECT 'Commenting' Type, c.CreationDate, c.UserId
  FROM Comments c
  UNION ALL
  SELECT 'Editing' Type, h.CreationDate, h.UserId
  FROM PostHistory h
  WHERE PostHistoryTypeId IN (4,5,6)
)

SELECT TOP 10 UserId [User Link], COUNT(*) TotalActions
FROM ActionHistory
WHERE CreationDate > DATEADD(month, -1, GETUTCDATE())
GROUP BY UserId
ORDER BY COUNT(*) DESC

Enter Parameters

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