本文介绍了SQL分组依据:使用where子句逻辑基于聚合函数过滤结果的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!
问题描述
我有一个基本的group by/avg语句:
I have a basic group by/avg statement:
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的结果.我该怎么做...?
What I want to do now is to drop any results which have a higher than average ping of 500. How can I do this...?
推荐答案
只需添加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分组依据:使用where子句逻辑基于聚合函数过滤结果的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持!