![]() ![]() This is achieved by adding the keyword WITH ROLLUP after GROUP BY and producesĪn identical result to the UNION query showing above (except that NULL is displayed as the label for total). ![]() In query 4 below, the output shows the number of orders aggregated for each order date and a total for the month is calculated and If there are multiple columns in the GROUP BY clause, ROLLUP can answer summary questions at multiple aggregated levels over all rows.Ī NULL value is produced as a column identifier to indicate the super-aggregated total. The WITH ROLLUP modifier allows a summary output that represents a higher-level or super-aggregate summarized value for the GROUP BY column(s). In MySQL, there is a better way to accomplish the total summary values calculation - use the WITH ROLLUP modifier in conjunction with GROUP BY clause. OrderDate ) as OrderDate ,Ĭount ( distinct t1.
0 Comments
Leave a Reply. |
AuthorWrite something about yourself. No need to be fancy, just an overview. ArchivesCategories |