The GROUPING() Function

Expand your knowledge on GROUP BY WITH ROLLUP with the GROUPING modifier.

We'll cover the following

MySQL provides a WITH ROLLUP modifier for a GROUP BY clause in a SELECT statement. The modifier that functions as a suffix to the GROUP BY’s list of expressions yields aggregate rows for the groups created through GROUP BY. This can be very helpful in scenarios where we would otherwise need to formulate a second query to retrieve the same information. A great example of this is the summary of car parts built by type and date:

Get hands-on with 1400+ tech skills courses.