SQL for Non-Programmers -- Homework Practice

0

Please login or register to vote for this query.

(click on this box to dismiss)

Economics Meta

Q&A about the site for professional and academic economists and analysts

WITH ActionHistory AS 
(
  SELECT 'Posting' Type, p.Id, p.CreationDate, p.OwnerUserId UserId
  FROM Posts p
  WHERE PostTypeId IN (1,2)
  UNION ALL
  SELECT 'Commenting' Type, c.Id, c.CreationDate, c.UserId
  FROM Comments c
  UNION ALL
  SELECT 'Editing' Type, h.Id, 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 to main site
loading Hold tight while we fetch your results