'interpretation of 'having' clause in sql
I just recently started learning SQL and MySQL. It's interesting but confusing. Here I have 3 queries; I am confused and can't get the differences in the queries because I get different output each time. Can you explain the exact meaning of the queries and what is the difference from each other.
Query 1:
SELECT CustomerID, Country
FROM Customers
GROUP BY Country
HAVING Count(CustomerID) >5;
Quesry 2:
SELECT Count(CustomerID), Country
FROM Customers
GROUP BY Country
HAVING CustomerID >5;
Query 3:
SELECT Count(CustomerID), Country
FROM Customers
GROUP BY Country
HAVING Count(CustomerID) >5;
Sources
This article follows the attribution requirements of Stack Overflow and is licensed under CC BY-SA 3.0.
Source: Stack Overflow
Solution | Source |
---|