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

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

Windows 11 Services Run Prompt

MySQL /

Start MySQL Server on Windows 11

MySQL Download Windows 11

MySQL /

Download & Install MySQL on Windows 11

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

Recent Posts

  • Flowchart Control structures
  • Draw a Square using Turtle Graphics
  • Flowgorithm File Errors
  • Write to Text File using Flowgorithm
  • Read Text File using Flowgorithm
  • Flowgorithm Turtle Graphics Flowchart
  • Update Flowgorithm to Latest Version
  • Flowgorithm File Symbols
  • Flowgorithm Turtle Graphics
  • Flowgorithm 3 New Features

Back to Top

Links

  • Contact
  • Privacy Policy
  • Cookie Policy

www.TestingDocs.com

Go to mobile version