WooCommerce answered/unanswered year over year

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

WITH ratio 
AS(
  SELECT
    DATEADD(YEAR, DATEDIFF(YEAR, 0, CreationDate), 0) AS AI, 
    COUNT(DISTINCT Posts.Id) AS Count,
    SUM(CASE WHEN Posts.AnswerCount > 0 THEN 1 ELSE 0 END) AS answered
  FROM Posts
    INNER JOIN PostTags ON PostTags.PostId = Posts.Id
    INNER JOIN Tags ON PostTags.TagId = Tags.Id
  WHERE Tags.TagName like 'woocommerce%'
    AND PostTypeId = 1 AND CreationDate > '2012-01-01'
  GROUP BY DATEADD(YEAR, DATEDIFF(YEAR, 0, CreationDate), 0)
)
SELECT 
  AI as 'Year',
  Count as 'Total Questions',
  answered*100 / Count as '% Answered'
From ratio
Order by Year DESC

Enter Parameters

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