gpt4 book ai didi

mysql - 将两行合二为一 - Mysql

转载 作者:行者123 更新时间:2023-11-29 01:10:16 25 4
gpt4 key购买 nike

我找到了一些类似的帖子,但我觉得它们没有用。但我不知道如何对它们进行分组。

我想将“No”和“Not Set”加到一行,并删除“Not Set”行。

所以:“否”=“否”+“未设置”

我有这样的东西:

TEST           TestCount        Month
'Yes' 123 March
'No' 432 March
'Not Set' 645 March
'Yes' 13 April
'No' 42 April
'Not Set' 45 April
'Yes' 133 May
'No' 41 May
'Not Set' 35 May
....

我想要这样的东西:

TEST           TestCount        Month
'Yes' 423 March (Should be 123? - @Dems)
'No' 410 March (Should be 1077? - @Dems)
'Yes' 154 April (Should be 13? - @Dems)
'No' 192 April (Should be 87? - @Dems)
'Yes' 130 May (Should be 133? - @Dems)
'No' 149 May (Should be 76? - @Dems)

....

任何人都可以帮助我,提前 tnx

最佳答案

SELECT  CASE test WHEN 'Not Set' THEN 'No' ELSE test END AS newtest,
month, SUM(testCount)
FROM mytable
GROUP BY
newtest, month

关于mysql - 将两行合二为一 - Mysql,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/10929997/

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