TestingDocs.com
Software Testing website
  • Automation
    • Selenium
    • JBehave Framework
  • Tutorials
    • MySQL Tutorials
    • Testlink
    • Maven
    • Git
  • IDEs
    • IntelliJ IDEA
    • Eclipse
  • Flowcharts
    • Flowgorithm
    • Raptor
  • About

MySQL

MySQL GROUP BY Clause

Overview

In this tutorial, we will learn about the MySQL GROUP BY Clause. A GROUP BY clause can be used based on the values in one or more columns of the selected group of rows.

MySQL GROUP BY Clause

A GROUP BY clause places selected rows into groups. Grouping is useful when we use aggregate functions. With a GROUP BY clause, an aggregate function calculates a summary value for each group.

Without a GROUP BY clause MySQL treats all the selected rows as a single group. The Aggregate function without GROUP BY clause calculates the result based on the entire set of rows.

For example, if a WHERE clause selects 15 rows and the GROUP BY arranges them into three groups of five rows each, an aggregate function produces the result for each of the three groups.

Example

For example, Let’s take the Country table from the MySQL world database. We can group the rows by Continent and calculate the sum population of countries in each continent.

mysql> SELECT Continent, SUM(Population)
-> FROM Country
-> GROUP BY Continent ;

+—————+—————–+
| Continent | SUM(Population) |
+—————+—————–+
| North America | 482993000 |
| Asia | 3705025700 |
| Africa | 784475000 |
| Europe | 730074600 |
| South America | 345780000 |
| Oceania | 30401150 |
| Antarctica | 0 |
+—————+—————–+
7 rows in set (0.01 sec)

 

 

MySQL Group By

—

MySQL Tutorials

MySQL Tutorials on this website:

https://www.testingdocs.com/mysql-tutorials-for-beginners/

For more information on MySQL Database:

https://www.mysql.com/

Related Posts

DataGrip Desktop Shortcut

MySQL /

Launch DataGrip on Windows

DataGrip Download

MySQL /

Install DataGrip IDE on Windows 11

MySQL Workbench Windows 11

MySQL /

New MySQL Connection in Workbench

MySQL Command-line Client

MySQL /

Command-Line MySQL Client

Start MySQL Client

MySQL /

Start MySQL Client on Windows 11

‹ Create a Table in MySQL Database› MySQL DROP DATABASE Statement

Recent Posts

  • MS Access Data Types
  • Install RAPTOR Avalonia on CentOS
  • Download RAPTOR Avalonia Edition on Windows
  • npm doctor command
  • Build & Run CLion Project
  • Create New CLion C Project on Windows
  • Configure CLion Toolchains on Windows
  • Launch CLion IDE on Windows
  • Activate CLion IDE
  • CLion IDE for C/C++ Development

Back to Top

Links

  • Contact
  • Privacy Policy
  • Cookie Policy

www.TestingDocs.com

Go to mobile version