Q&A about the site for mechanics and DIY enthusiast owners of cars, trucks, and motorcycles
SELECT COUNT(P.Id) AS Num_Posts, SUM(CASE WHEN C.PostId IS NULL THEN 1 ELSE 0 END) AS Posts_NoComments, (SUM(CASE WHEN C.PostId IS NULL THEN 1 ELSE 0 END) / COUNT(P.Id)) * 100 AS Percent_NoComments, SUM(CASE WHEN C.PostId IS NULL THEN 1 ELSE 0 END) / COUNT(P.Id) * 100 AS Percent_NoComments FROM Posts P LEFT JOIN Comments C ON C.PostId = P.Id