gpt4 book ai didi

mysql - 在mysql查询中更改结果

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

我想操纵从查询中获得的结果。

我有一组 250 万行,一个状态有 10 个不同的 ID。这些状态没有映射到另一个表中,但我想操纵我在 SQLyog 中获得的结果。

What I would like to do is:

Count(Id) | Status
------------------
500.000 | 1
750.000 | 2

convert into a result

Count(Id) | Status
-------------------
500.000 | Initial order
750.000 | Cancelled

这可以在查询中完成吗?请注意,我没有使用 PHP 或浏览器来显示结果。

最佳答案

select 
count(*) as TotalRecs,
case status
when 1 then "Initial Order"
when 2 then "Cancelled "
when 3 then "whatever "
else "all others "
end case as WordStatus
from
YourTable
group by
2

关于mysql - 在mysql查询中更改结果,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/4738187/

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