SQL GROEP DEUR Sleutelwoord
GROEPEER VOLGENS
Die GROUP BY
opdrag word gebruik om die resultaatstel te groepeer (gebruik met totale funksies: COUNT, MAX, MIN, SUM, AVG).
Die volgende SQL lys die aantal kliënte in elke land:
Voorbeeld
SELECT COUNT(CustomerID), Country
FROM Customers
GROUP BY Country;
Die volgende SQL lys die aantal kliënte in elke land, hoog na laag gesorteer:
Voorbeeld
SELECT COUNT(CustomerID), Country
FROM Customers
GROUP BY Country
ORDER BY COUNT(CustomerID) DESC;