Skip to content

Instantly share code, notes, and snippets.

@mhkt
Created March 13, 2013 23:03
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 mhkt/5157266 to your computer and use it in GitHub Desktop.
Save mhkt/5157266 to your computer and use it in GitHub Desktop.
select tag.*, count(*) as count from tag
LEFT OUTER JOIN category_tag ON tag.name_encoded = category_tag.name_encoded
WHERE category_tag.name_encoded IS NULL
GROUP BY tag.name_encoded
ORDER BY count DESC
LIMIT 1;
SELECT tag.*, count(*) as count FROM category_tag.name_encoded
JOIN tag ON tag.name_encoded = category_tag.name_encoded
WHERE category_tag.name_encoded IS NULL
GROUP BY tag.name_encoded
ORDER BY count DESC;
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment