gpt4 book ai didi

MySQL 查询 : count entries by status

转载 作者:太空宇宙 更新时间:2023-11-03 11:14:17 24 4
gpt4 key购买 nike

我有一个具有以下架构的日志表:

OperatorId - JobId - Status ( Good/Bad/Ugly )
Alex 6 Good
Alex 7 Good
James 6 Bad

描述:每当运算符(operator)处理一项工作时,都会生成一个条目以及状态。就是这样。

现在我需要这样的报告:

OperatorId - Good Count - Bad Count - Ugly Count
Alex 2 0 0
James 0 1 0

最佳答案

select operatorid,
sum(if(status="good",1,0)) as good,
sum(if(status="bad",1,0)) as bad,
sum(if(status="ugly",1,0)) as ugly
from table
group by operatorid

关于MySQL 查询 : count entries by status,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/6239109/

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