Skip to content

Instantly share code, notes, and snippets.

@stevommmm
Created October 17, 2014 12:43
Show Gist options
  • Save stevommmm/07b0a7d9b9e912124117 to your computer and use it in GitHub Desktop.
Save stevommmm/07b0a7d9b9e912124117 to your computer and use it in GitHub Desktop.
SELECT type, SUM(created) AS created, SUM(destroyed) AS destroyed FROM (
(SELECT type, count(type) AS created, 0 AS destroyed FROM `lb-world` INNER JOIN `lb-players` USING (playerid) WHERE playername = 'DOKDOR' AND type > 0 AND type != replaced $dateClause GROUP BY type)
UNION
(SELECT replaced AS type, 0 AS created, count(replaced) AS destroyed FROM `lb-world` INNER JOIN `lb-players` USING (playerid) WHERE playername = 'DOKDOR' AND replaced > 0 AND type != replaced $dateClause GROUP BY replaced)
) AS t GROUP BY type ORDER BY SUM(created) + SUM(destroyed) DESC
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment