我想显示字段尝试的总和以及连接在一起的点的总和,但我只得到字段尝试的总和。
SELECT
ContactName,
SUM(CASE WHEN event = 'Event1' THEN tries || '/' || points END) AS "E1",
SUM(CASE WHEN event = 'Event2' THEN tries || '/' || points END) AS "E2",
SUM(CASE WHEN event = 'Event3' THEN tries || '/' || points END) AS "E3",
FROM names
WHERE
period = 2
GROUP BY
ContactName
答案 0 :(得分:1)
我通过划分两个总和
来做到以下几点SUM(CASE WHEN event = 'Event1' THEN tries END) || "/" || SUM(CASE WHEN event = 'Event1' THEN points END) AS "E1"