Skip to content

Instantly share code, notes, and snippets.

@tegansnyder
Created March 19, 2014 21:46
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save tegansnyder/9652098 to your computer and use it in GitHub Desktop.
Save tegansnyder/9652098 to your computer and use it in GitHub Desktop.
Search result counts (no results) breakdown by year/month
SELECT COUNT(query_id) AS no_results_count,
y,
m
FROM
(SELECT cq.query_id,
MONTH(cq.updated_at) AS m,
YEAR(cq.updated_at) AS y
FROM catalogsearch_query cq
WHERE cq.num_results = 0
ORDER BY cq.popularity DESC) sub_query
GROUP BY sub_query.m
ORDER BY y DESC,
m DESC
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment