gpt4 book ai didi

mysql - 在查询中使用having子句两次

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

我有两个疑问

select a,b,c,count(d) as first_count from
test
group by a,b,c
having (count(c)>1)

第二个

    select a,b,c,count(d) as second_count  from
test
group by a,b,c
having (count(c)>100)

如何在一个查询中执行上述操作,以便在我的结果中具有以下列:a,b,c,count(d) as first_count,count(d) as secondary_count

最佳答案

也许这会对你有帮助

 select a,b,c,(select count(d)  from test having (count(c)>1) )   as first_count,
(select count(d) from test having (count(c)>100) ) as second_count
FROM test
group by a,b,c

关于mysql - 在查询中使用having子句两次,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/22463927/

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