Totals of the various types of posts

0

Please login or register to vote for this query.

(click on this box to dismiss)

Stack Overflow

Q&A for professional and enthusiast programmers

SELECT MAX(pt.Name) AS 'Post Type', COUNT(pwd.Id) AS 'Total',
    COUNT(pwd.Id) - COUNT(CAST(pwd.DeletionDate AS int)) as 'Live',
    COUNT(CAST(pwd.DeletionDate AS int)) AS 'Deleted'

FROM PostTypes pt
JOIN PostsWithDeleted pwd on pt.Id = pwd.PostTypeId

GROUP BY pt.Id

Enter Parameters

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