Safari Books Online is a digital library providing on-demand subscription access to thousands of learning resources.
Consider the following GROUP BY clause which summarizes the hours worked by an employee for each project. We can see from these results the total hours ‘Smith’ has worked on ‘ProductX’ or the total hours ‘Smith’ has worked on ‘ProductY’. However, while we are grouping by project and employee, there are no totals that are produced for those categories.
In the example below we include the ROLLUP() option within the GROUP BY clause. This will produce subtotals for the first GROUP BY column. In the example below, notice how the hours worked are totaled by project. A grand total of hours is also shown. For readability, these additional rows have been highlighted in the result table with shading and inserted blank lines.