SELECT *, * FROM PostsWithDeleted WHERE PostTypeId = 1 UN...

0

Please login or register to vote for this query.

(click on this box to dismiss)

DevOps

Q&A for software engineers working on automated testing, continuous delivery, service integration and monitoring, and building SDLC infrastructure

SELECT *, *
FROM PostsWithDeleted 
WHERE PostTypeId = 1
UNION ALL SELECT a.*, q.*
FROM PostsWithDeleted q INNER JOIN PostsWithDeleted a ON q.Id = a.ParentId
--WHERE a.PostTypeId = 2

/*
SELECT
  'All',
  SUM(CASE PostTypeId WHEN 2 THEN 1 ELSE 0 END) Answers,
  SUM(CASE PostTypeId WHEN 1 THEN 1 ELSE 0 END) Questions
FROM PostsWithDeleted

UNION ALL SELECT
  'Open and not deleted',
  SUM(CASE PostTypeId WHEN 2 THEN 1 ELSE 0 END) Answers,
  SUM(CASE PostTypeId WHEN 1 THEN 1 ELSE 0 END) Questions
FROM PostsWithDeleted WHERE DeletionDate IS NULL AND ClosedDate IS NULL

UNION ALL SELECT
  'Not deleted',
  SUM(CASE PostTypeId WHEN 2 THEN 1 ELSE 0 END) Answers,
  SUM(CASE PostTypeId WHEN 1 THEN 1 ELSE 0 END) Questions
FROM PostsWithDeleted WHERE DeletionDate IS NULL
*/

Enter Parameters

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