52.生成记分牌

在jungleville,延长赛是一个常规的事情。记分牌可以用来跟踪的竞争,谁赢得了。

user_id = 0004的记分牌是什么样子?

SELECT stats.uuid AS player, hist.uuid AS opponent, 
    SUM(CASE WHEN hist.result = "won" THEN 1 ELSE 0 END) AS wins, 
    SUM(CASE WHEN hist.result = "lost" THEN 1 ELSE 0 END) AS losses
FROM jungleville_stats AS stats 
    USE KEYS "zid-jungle-stats-0004" 
UNNEST stats.`pvp-hist` AS hist
GROUP BY stats.uuid, hist.uuid

结果:

{
  "results": [
    {
      "losses": 0,
      "opponent": "zid-jungle-0007",
      "player": "zid-jungle-0004",
      "wins": 1
    },
    {
      "losses": 0,
      "opponent": "zid-jungle-0001",
      "player": "zid-jungle-0004",
      "wins": 1
    },
    {
      "losses": 0,
      "opponent": "zid-jungle-0003",
      "player": "zid-jungle-0004",
      "wins": 1
    }
  ]
}

Last updated

Was this helpful?