gpt4 book ai didi

mysql - 总结初始列 mysql

转载 作者:行者123 更新时间:2023-11-30 00:44:57 25 4
gpt4 key购买 nike

我创建了一个这样的查询

 "select count(if(gender="male",1,null)) as malecount,
count(if(gender="female",1,null)) as femalecount from biodata"

这是工作,我想总结一下这个计数:

 "select count(if(gender="male",1,null)) as malecount,
count(if(gender="female",1,null)) as femalecount, male+female as sumgender
from biodata"

当然,当我在 if 语句中设置许多条件时,该查询会有所帮助

请帮我解决这个问题...

最佳答案

这样写可以解决问题

select malecount+femalecount as sumcount from  (select
count(if(gender="male",1,null)) as malecount,
count(if(gender="female",1,null)) as femalecount from biodata) as
query

关于mysql - 总结初始列 mysql,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/21455568/

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