English

What is the purpose of the following clause in a select statement? GROUP BY

Advertisements
Advertisements

Question

What is the purpose of the following clause in a select statement?

GROUP BY

Short/Brief Note
Advertisements

Solution

The GROUP BY clause is used in the SELECT statement, to divide the table into groups i.e combines all records that have identical values in a particular field.

Grouping can be done by a common column name or with aggregate functions in which case the aggregate produces a value for each.

For example:

mysql> SELECT GENDER, COUNT(*) FROM STUDENT GROUP BY GENDER;

OUTPUT:

GENDER COUNT(*)

MALE 20

FEMALE 15

shaalaa.com
GROUP BY Clause in SQL
  Is there an error in this question or solution?
Chapter 9: Structured Query Language (SQL) - Exercise [Page 176]

APPEARS IN

NCERT Computer Science [English] Class 12
Chapter 9 Structured Query Language (SQL)
Exercise | Q 1. b) ii) | Page 176
Share
Notifications

Englishहिंदीमराठी


      Forgot password?
Use app×