gpt4 book ai didi

android - 如何在 Android 上的 SQLite 中使用 CASE WHEN 对两个字段求和

转载 作者:行者123 更新时间:2023-11-29 01:21:48 26 4
gpt4 key购买 nike

我想显示现场尝试的总和和连接在一起的点的总和,但我只得到现场尝试的总和。

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

最佳答案

我通过将两个总和相除进行了以下操作

SUM(CASE WHEN event = 'Event1' THEN tries END) || "/" || SUM(CASE WHEN event = 'Event1' THEN points END) AS "E1"

关于android - 如何在 Android 上的 SQLite 中使用 CASE WHEN 对两个字段求和,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/36390225/

26 4 0
Copyright 2021 - 2024 cfsdn All Rights Reserved 蜀ICP备2022000587号
广告合作:1813099741@qq.com 6ren.com