Are less SQL questions asked at weekends?

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
  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;

Enter Parameters

Options:
Switch to meta site
loading Hold tight while we fetch your results