I recognize the purpose of GROUP BY x.

However, how do GROUP BY X, Y operate and what does it signify?
Sep 2, 2022 421 views

## 1 answer to this question.

Group By X means to put all those with the same value for X in one group.

Group By X, Y means to put all those with the same values for both X and Y in one group.

Let's use the following table, which pertains to which university students are enrolled in which subjects, as an illustration:

```Table: Subject_Selection

+---------+----------+----------+
| Subject | Semester | Attendee |
+---------+----------+----------+
| ITB001  |        1 | John     |
| ITB001  |        1 | Bob      |
| ITB001  |        1 | Mickey   |
| ITB001  |        2 | Jenny    |
| ITB001  |        2 | James    |
| MKB114  |        1 | John     |
| MKB114  |        1 | Erica    |
+---------+----------+----------+
```

When you use a group by on the subject column only; say:

```select Subject, Count(*)
from Subject_Selection
group by Subject
```

Output:

```+---------+-------+
| Subject | Count |
+---------+-------+
| ITB001  |     5 |
| MKB114  |     2 |
+---------+-------+```

Unlock the power of data and embark on a journey towards becoming a skilled data scientist. Join our comprehensive Data Science Training program today!

• 63,420 points

## Add two lines on graph using abline in R

I am using "y 0+x" to fit ...READ MORE

## Filter multiple values on a string column in dplyr

The filter() function is used to select ...READ MORE

## Converting xlsx to xls using Microsoft Office Compitablity Pack's excelcnv

Simply rearranging the positions of the parameters ...READ MORE

## Reasons for using the set.seed function

The requirement is a desire for repeatable ...READ MORE

## Using ORDER BY and GROUP BY together

Correctly use the  group by: select l.* from table ...READ MORE

## How to use count and group by at the same select statement

This will do what you want (list of ...READ MORE