Home > Software engineering >  SQL Group By within Category
SQL Group By within Category

Time:12-10

How can we use group by within separate categories? That is treat each category as it's own group and then group by something else within the category.

For instance in this Image, I would like to group by quarter only within a particular ISSN. enter image description here

CodePudding user response:

It is possible to group by more than one column:

select issn, quarter, count(*)
from t
group by issn, quarter

CodePudding user response:

Simply add columns -as prioritized- to group by, example:

SELECT * FROM MyTable GROUP BY ISSN, Quarter
  • Related