gpt4 book ai didi

mysql - MySQL 中是否可以有条件地计数和添加行标签?

转载 作者:行者123 更新时间:2023-11-29 06:54:46 24 4
gpt4 key购买 nike

我有一个数据集

HAPPY
1
0
0
0
0
1
1

我想统计返回的 1 和 0

Status | Count
YES | 3
NO | 4

最佳答案

select if (HAPPY=1, 'YES', 'NO') as Status,
count(HAPPY) as Count from Table1 group by HAPPY order by Status desc;

关于mysql - MySQL 中是否可以有条件地计数和添加行标签?,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/46065058/

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