Tuesday, November 1, 2022

What is Group By in SQL

 The GROUP BY statement groups rows that have the same values into summary rows, like "find the number of customers in each country".


The GROUP BY statement is often used with aggregate functions (COUNT()MAX()MIN()SUM()AVG()) to group the result-set by one or more columns.

Example:

SELECT COUNT(CustomerID), Country
FROM Customers
GROUP BY Country;





No comments:

Post a Comment

How to use SQL pagination using LIMIT and OFFSET

  How to extract just a portion of a larger result set from a SQL SELECT. LIMIT n is an alternative syntax to the FETCH FIRST n ROWS ONLY. T...