SQL中的HAVING和WHERE有什么区别? [英] What is the difference between HAVING and WHERE in SQL?

查看:83
本文介绍了SQL中的HAVING和WHERE有什么区别?的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

SQL SELECT语句中的HAVINGWHERE有什么区别?

What is the difference between HAVING and WHERE in an SQL SELECT statement?

我已将史蒂文的答案标记为正确的答案,因为它包含链接上的关键信息:

I have marked Steven's answer as the correct one as it contained the key bit of information on the link:

不使用GROUP BY时,HAVING的行为类似于WHERE子句

When GROUP BY is not used, HAVING behaves like a WHERE clause

我所见过的WHERE的情况没有GROUP BY,这是我开始困惑的地方.当然,除非您知道这一点,否则无法在问题中指定它.

The situation I had seen the WHERE in did not have GROUP BY and is where my confusion started. Of course, until you know this you can't specify it in the question.

推荐答案

HAVING指定一个搜索条件 组或SELECT语句中使用的聚合函数.

HAVING specifies a search condition for a group or an aggregate function used in SELECT statement.

查看全文

登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆