SQL for Non-Programmers -- Homework Practice

0

Please login or register to vote for this query.

(click on this box to dismiss)

Physics

Q&A for active researchers, academics and students of physics

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

Enter Parameters

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