GROUPING SETS make it possible to apply many GROUP BY clauses in one single query. Moreover, this new feature introduces the notion of a ROLLUP, which is an extra row added to the result set that gives a summary of the results as a super-aggregate of previously returned values. Let's give a very simple example using the employees table in the test database. Let's execute the following query in the phpMyAdmin web interface:
SELECT superior AS manager_id, SUM(salary)FROM employeesWHERE superior IS NOT NULLGROUP BY manager_id, salary;
Once executed, you should see this result: