MySQL Tutorial – The GROUP BY clause

The GROUP BY clause

The GROUP BY clause is used to group similar data specified by a certain field in your table.

The GROUP BY clause syntax:

SELECT column_name(s)
FROM table_name
GROUP BY column_name;

Let’s see some example of GROUP BY clause:

SELECT position
FROM employee_record
GROUP BY position;

Result:

+-----------------------+
| position              |
+-----------------------+
| Encoder               |
| Network Administrator |
| Programmer            |
| System Analyst        |
+-----------------------+
4 rows in set (0.00 sec)
, , ,

Post navigation

Leave a Reply

Your email address will not be published. Required fields are marked *

This site uses Akismet to reduce spam. Learn how your comment data is processed.