Q&A for professional and enthusiast programmers
SELECT CAST(PostSqlity.CreationDateTime AS DATE) AS CalendarDate, -- SUM(PostSqlity.HasTagSql) AS SqlPostCount, -- COUNT(PostSqlity.Id) AS TotalPostCount, CAST(SUM(PostSqlity.HasTagSql) AS FLOAT) / COUNT(PostSqlity.Id) AS SqlityRatio FROM ( SELECT Posts.Id, Posts.CreationDate AS CreationDateTime, COUNT(Tags.TagName) AS HasTagSql FROM Posts INNER JOIN PostTags ON Posts.Id = PostTags.PostId LEFT JOIN Tags ON Tags.Id = PostTags.TagId AND Tags.TagName = 'sql' GROUP BY Posts.Id, Posts.CreationDate ) AS PostSqlity GROUP BY CAST(CreationDateTime AS DATE) ORDER BY CalendarDate DESC;