gpt4 book ai didi

MYSQL:查询合并计数

转载 作者:行者123 更新时间:2023-11-29 12:07:40 25 4
gpt4 key购买 nike

sql:

SELECT 
id, COUNT(id) AS Counter
FROM tableA
GROUP BY id

结果:

enter image description here

目标是执行以下操作:

enter image description here

将 (NULL ID) 与 ID=09 组合起来,这样它就会 0+1=1,给 id 适当的命名也很好,就像

ID             Counter
NULLWITH09 1
THE 01 467
THE 02 8

任何帮助都会很棒..谢谢

最佳答案

未经测试,但类似这样:

SELECT 
'THE ' +id, COUNT(id) AS Counter
FROM tableA
where id is not null and id<>9
GROUP BY id
UNION ALL
SELECT
'null and 9', COUNT(*) AS Counter
FROM tableA
where id is null or id=9

关于MYSQL:查询合并计数,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/31197708/

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