Don't like ads? PRO users don't see any ads ;-)
Guest

LogBlockWebStats SQL

By: a guest on Jun 17th, 2012  |  syntax: None  |  size: 1.54 KB  |  hits: 19  |  expires: Never
download  |  raw  |  embed  |  report abuse  |  print
Text below is selected. Please press Ctrl+C to copy to your clipboard. (⌘+C on Mac)
  1. Where to get: [LogBlockWebStats](https://github.com/DiddiZ/LogBlockWebStats/wiki/Installation)
  2.  
  3. ## Examples:
  4.  
  5. * [insane-architects.net](http://insane-architects.net/?page=lbstats)
  6.  
  7. ![preview](http://h3.abload.de/img/lbwebstats3ial.png)
  8.  
  9. * [stats.minr.org](http://stats.minr.org/)
  10.  
  11. ![preview](http://stats.minr.org/screen.png)
  12.  
  13. _If you've own webstats using LogBlock, add a link, or tell me about so I can do it_
  14.  
  15. ## For developers:
  16. The basic queries are:
  17. ```SQL
  18. SELECT playername, SUM(created) AS created, SUM(destroyed) AS destroyed
  19. FROM (
  20.         (
  21.                 SELECT playerid, count(type) AS created, 0 AS destroyed
  22.                 FROM `lb-main` WHERE type > 0 AND type != replaced
  23.                 GROUP BY playerid
  24.         ) UNION (
  25.                 SELECT playerid, 0 AS created, count(replaced) AS destroye
  26.                 FROM `lb-main` WHERE replaced > 0 AND type != replaced
  27.                 GROUP BY playerid
  28.         )
  29. ) AS t
  30. INNER JOIN `lb-players` USING (playerid)
  31. GROUP BY playerid
  32. ORDER BY SUM(created) + SUM(destroyed) DESC
  33. ```
  34. and:
  35. ```SQL
  36. SELECT type, SUM(created) AS created, SUM(destroyed) AS destroyed
  37. FROM (
  38.         (
  39.                 SELECT type, count(type) AS created, 0 AS destroyed
  40.                 FROM `lb-main` INNER JOIN `lb-players` USING (playerid)
  41.                 WHERE playername = '$player' AND type > 0 AND type != replaced
  42.                 GROUP BY type
  43.         ) UNION (
  44.                 SELECT replaced AS type, 0 AS created, count(replaced) AS destroyed
  45.                 FROM `lb-main` INNER JOIN `lb-players` USING (playerid)
  46.                 WHERE playername = '$player' AND replaced > 0 AND type != replaced
  47.                 GROUP BY replaced
  48.         )
  49. ) AS t
  50. GROUP BY type
  51. ORDER BY SUM(created) + SUM(destroyed) DESC
  52. ```