bugl
bugl
HomeLearnPatternsSearch
HomeLearnPatternsSearch

Loading lesson path

Learn/SQL/SQL References
SQL•SQL References

SQL GROUP BY Keyword

Concept visual

SQL GROUP BY Keyword

Pointer walk
two pointers
leftright102132436485116
left=0
right=6
1
3

Start at both ends

GROUP BY Keyword

Previous

❮ SQL Keywords

Next

Group By

The GROUP BY

command is used to group the result set (used with aggregate functions: COUNT, MAX, MIN, SUM, AVG). The following SQL lists the number of customers in each country:

Example

SELECT COUNT(CustomerID), Country

FROM Customers

GROUP BY Country;

The following SQL lists the number of customers in each country, sorted high to low:

Example

SELECT COUNT(CustomerID), Country

FROM Customers

GROUP BY Country

ORDER BY COUNT(CustomerID) DESC;

Previous

❮ SQL Keywords

Next

Previous

SQL FULL OUTER JOIN Keyword

Next

SQL HAVING Keyword