Count of existing and deleted posts by their type


Please login or register to vote for this query.

(click on this box to dismiss)

Stack Overflow

Q&A for professional and enthusiast programmers

  MIN(PostTypes.Name) AS Name,
  PostTypes.Id AS PostTypeId,
  COUNT(PostsWithDeleted.Id) AS AllCount,
  COUNT(DeletionDate) AS DeletedCount
FROM PostTypes
LEFT JOIN PostsWithDeleted ON PostsWithDeleted.PostTypeId = PostTypes.Id
GROUP BY PostTypes.Id
ORDER BY AllCount DESC, PostTypes.Id

Enter Parameters

Switch sites:
loading Hold tight while we fetch your results