gpt4 book ai didi

MySQL Group By Query X or not X

转载 作者:可可西里 更新时间:2023-11-01 07:58:00 25 4
gpt4 key购买 nike

这应该很容易,但我还没有找到答案。我有一个正在运行计数的查询,我想在查询中将其分组为 State = 1 和 State <>1 的那些,并计算每组的总和。

SELECT count(`id_job`) as count, `state` 
FROM job_table
GROUP BY `state`;

最佳答案

您也可以查询 bool 表达式并对其进行分组:

SELECT   state = 1, COUNT(*)
FROM job_table
GROUP BY state = 1

关于MySQL Group By Query X or not X,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/46603802/

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