jjzjj

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

coder 2023-10-14 原文

我有一个基本的 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/

有关SQL 分组依据 : using where-clause logic to filter results based on aggregate functions的更多相关文章

随机推荐