我想从一个简单的数据库表中提取名称、#kills、#deaths。
表有
_from(杀手),_to(死者),然后是事件的窃听。在 pvp 的情况下,我们想计算这个人是死了还是被杀了,然后把它加到他们的总数中
这可以通过查询来完成,还是我必须编写脚本?这不起作用@ all:
SELECT (select COUNT( _from ) from wiretaps group by _from) as num_kills,
(select COUNT( _to ) from wiretaps group by _to) as num_deaths,
_from as name
FROM wiretaps
WHERE message LIKE "%PvP:%"
http://sqlfiddle.com/#!2/1e5d9/1
| _FROM | _TO | MESSAGE | ID |
---------------------------------
| naez | salty | PvP: | 1 |
| naez | prince | PvP: | 2 |
| chuck | naez | PvP: | 3 |
预期输出:
| name | num_kills | num_deaths |
---------------------------------
| naez | 2 | 1 |
| prince | 0 | 1 |
| chuck | 1 | 0 |
| salty | 0 | 1 |