当前位置: 代码迷 >> SQL >> [Teach Youself SQL in 十 Minutes] The difference between HAVING and WHERE
  详细解决方案

[Teach Youself SQL in 十 Minutes] The difference between HAVING and WHERE

热度:160   发布时间:2016-05-05 14:07:23.0
[Teach Youself SQL in 10 Minutes] The difference between HAVING and WHERE

?

The difference between HAVING and WHERE Here's another way to look it: WHERE filters before data is grouped, and HAVING filters after data is grouped. This is an important distinction; rows that are eliminated by a WHERE clause will not be included in the group. This could change the calculated values which in turn could affect which groups are filtered based on the use of those values in the HAVING clause.

?

?

Using HAVING and WHERE HAVING is so similar to WHERE that most DBMSs treat them as the same thing if no GROUP BY is specified. Nevertheless, you should make that distinction yourself. Use HAVING only in conjunction with GROUP BY clauses. Use WHERE for standard row-level filtering.

?

?

BTW:

The only difference is that WHERE filters rows and HAVING filters groups.

The difference between HAVING and WHERE Here's another way to look it: WHERE filters before data is grouped, and HAVING filters after data is grouped.

  相关解决方案