Count of existing and deleted posts by their type

1

Please login or register to vote for this query.

(click on this box to dismiss)

Stack Overflow

Q&A for programmers

SELECT
  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

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