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:
The following SQL lists the number of customers in each country, sorted high to low:
SELECT COUNT(CustomerID), Country
FROM Customers
GROUP BY Country
ORDER BY COUNT(CustomerID) DESC;
Try it Yourself »
截取页面反馈部分,让我们更快修复内容!也可以直接跳过填写反馈内容!