SELECT *, 1.0 * Deleted / Total FROM ( SELECT COUNT(CASE ...

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
  *,
  1.0 * Deleted / Total
FROM (
  SELECT
    COUNT(CASE WHEN DeletionDate IS NOT NULL THEN 1 ELSE NULL END) Deleted,
    COUNT(CASE WHEN DeletionDate IS NULL THEN 1 ELSE NULL END) Remaining,
    COUNT(*) Total
  FROM
    PostsWithDeleted
  WHERE
    PostTypeId IN (1, 2)
) x

Enter Parameters

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