3

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

我现在想要做的是删除任何高于平均 500 ping 的结果。我该怎么做......?

4

1 回答 1

13

只需添加一个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;
于 2010-03-19T21:12:57.003 回答