gpt4 book ai didi

SQL 分组依据 : using where-clause logic to filter results based on aggregate functions

转载 作者:可可西里 更新时间:2023-11-01 07:47:05 26 4
gpt4 key购买 nike

我有一个基本的 group by/avg 语句:

select url, avg(contentping+tcpping), count(*) from websites ws, ping pi 
where ws.idwebsite = pi.idwebsite and errortype is null
group by url order by avg(contentping+tcpping) asc;

我现在想做的是删除所有 ping 值高于平均 500 的结果。我该怎么做...?

最佳答案

只需添加一个having 子句:

select url, avg(contentping+tcpping), count(*) from websites ws, ping pi 
where ws.idwebsite = pi.idwebsite and errortype is null
group by url
having avg(contenetping+tcpping) < 500
order by avg(contentping+tcpping) asc;

关于SQL 分组依据 : using where-clause logic to filter results based on aggregate functions,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/2480613/

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