Skip to content

Instantly share code, notes, and snippets.

@nsanden
Created September 23, 2015 22:51
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 nsanden/f932dbe75194d923ecb3 to your computer and use it in GitHub Desktop.
Save nsanden/f932dbe75194d923ecb3 to your computer and use it in GitHub Desktop.
whatever.sql
SELECT `keyword`.`keyword`, COUNT(DISTINCT campaign_keyword.campaign_id) AS metric_value
FROM `keyword`
LEFT JOIN `campaign_keyword` ON campaign_keyword.keyword_id = keyword.id
GROUP BY `keyword`.`id`
ORDER BY `metric_value`
DESC LIMIT 100
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment