-- GROUP BY with one parameter:SELECT column_name, AGGREGATE_FUNCTION(column_name)FROM table_nameWHERE column_name operator valueGROUP BY column_name;
-- GROUP BY with two parameters:SELECTcolumn_name1,column_name2,AGGREGATE_FUNCTION(column_name3)FROMtable_nameGROUP BYcolumn_name1,column_name2;
SELECTcategoryId, categoryName, productId, SUM(unitPrice)FROMProducts pINNER JOINCategories c ON c.categoryId = p.categoryIdGROUP BY categoryId, productId
SELECT `_c5`,`_c7`,count(*) FROM res GROUP BY `_c5`,`_c7`
+--------------------+-------------------+--------+| _c5| _c7|count(1)|+--------------------+-------------------+--------+| Friendly| Southern Rhodesia| 11|| Friendly| Ecuador| 68||African Cup of Na...| Ethiopia| 41||Gold Cup qualific...|Trinidad and Tobago| 9||AFC Asian Cup qua...| Bhutan| 7||African Nations C...| Gabon| 2|| Friendly| China PR| 170||FIFA World Cup qu...| Israel| 59||FIFA World Cup qu...| Japan| 61||UEFA Euro qualifi...| Romania| 62||AFC Asian Cup qua...| Macau| 9|| Friendly| South Sudan| 1||CONCACAF Nations ...| Suriname| 3|| Copa Newton| Argentina| 12|| Friendly| Philippines| 38||FIFA World Cup qu...| Chile| 68||African Cup of Na...| Madagascar| 29||FIFA World Cup qu...| Burkina Faso| 30|| UEFA Nations League| Denmark| 4|| Atlantic Cup| Paraguay| 2|+--------------------+-------------------+--------+