Difference between Having and Where in SQL, sqlhavingwhere

Source: Internet
Author: User

Difference between Having and Where in SQL, sqlhavingwhere

Description

Where

Select before grouping

Having

Having can select an aggregation function only after grouping.
Eg:

// Select count (*) from awhere a. a1> 0 group by a2;
// However, select count (*) from awhere a. a1> 0 and count (*)> 1 group by a2;
// You must change the value to havingSELECT COUNT (*) from awhere a. a1> 0 group by a2HAVING COUNT (*)> 1.
Articles you may be interested in:
  • Difference between having and where in SQL
  • Difference between where and having in SQL statements

Related Article

Contact Us

The content source of this page is from Internet, which doesn't represent Alibaba Cloud's opinion; products and services mentioned on that page don't have any relationship with Alibaba Cloud. If the content of the page makes you feel confusing, please write us an email, we will handle the problem within 5 days after receiving your email.

If you find any instances of plagiarism from the community, please send an email to: info-contact@alibabacloud.com and provide relevant evidence. A staff member will contact you within 5 working days.

A Free Trial That Lets You Build Big!

Start building with 50+ products and up to 12 months usage for Elastic Compute Service

  • Sales Support

    1 on 1 presale consultation

  • After-Sales Support

    24/7 Technical Support 6 Free Tickets per Quarter Faster Response

  • Alibaba Cloud offers highly flexible support services tailored to meet your exact needs.