
LogBlockWebStats SQL
By: a guest on
Jun 17th, 2012 | syntax:
None | size: 1.54 KB | hits: 19 | expires: Never
Where to get: [LogBlockWebStats](https://github.com/DiddiZ/LogBlockWebStats/wiki/Installation)
## Examples:
* [insane-architects.net](http://insane-architects.net/?page=lbstats)

* [stats.minr.org](http://stats.minr.org/)

_If you've own webstats using LogBlock, add a link, or tell me about so I can do it_
## For developers:
The basic queries are:
```SQL
SELECT playername, SUM(created) AS created, SUM(destroyed) AS destroyed
FROM (
(
SELECT playerid, count(type) AS created, 0 AS destroyed
FROM `lb-main` WHERE type > 0 AND type != replaced
GROUP BY playerid
) UNION (
SELECT playerid, 0 AS created, count(replaced) AS destroye
FROM `lb-main` WHERE replaced > 0 AND type != replaced
GROUP BY playerid
)
) AS t
INNER JOIN `lb-players` USING (playerid)
GROUP BY playerid
ORDER BY SUM(created) + SUM(destroyed) DESC
```
and:
```SQL
SELECT type, SUM(created) AS created, SUM(destroyed) AS destroyed
FROM (
(
SELECT type, count(type) AS created, 0 AS destroyed
FROM `lb-main` INNER JOIN `lb-players` USING (playerid)
WHERE playername = '$player' AND type > 0 AND type != replaced
GROUP BY type
) UNION (
SELECT replaced AS type, 0 AS created, count(replaced) AS destroyed
FROM `lb-main` INNER JOIN `lb-players` USING (playerid)
WHERE playername = '$player' AND replaced > 0 AND type != replaced
GROUP BY replaced
)
) AS t
GROUP BY type
ORDER BY SUM(created) + SUM(destroyed) DESC
```