Questions tagged [rollup]

The ROLLUP operator is useful in generating reports that contain subtotals and totals. The ROLLUP operator generates a result set that is similar to the result sets generated by the CUBE operator

The ROLLUP operator is useful in generating reports that contain subtotals and totals. The ROLLUP operator generates a result set that is similar to the result sets generated by the CUBE operator. For more information, see Summarizing Data Using CUBE.

Following are the specific differences between CUBE and ROLLUP:

  • CUBE generates a result set that shows aggregates for all combinations of values in the selected columns.
  • ROLLUP generates a result set that shows aggregates for a hierarchy of values in the selected columns.

For example, a simple table Inventory contains the following:

Item                 Color                Quantity                   
-------------------- -------------------- -------------------------- 
Table                Blue                 124                        
Table                Red                  223                        
Chair                Blue                 101                        
Chair                Red                  210 

The next query

SELECT CASE WHEN (GROUPING(Item) = 1) THEN 'ALL'
            ELSE ISNULL(Item, 'UNKNOWN')
       END AS Item,
       CASE WHEN (GROUPING(Color) = 1) THEN 'ALL'
            ELSE ISNULL(Color, 'UNKNOWN')
       END AS Color,
       SUM(Quantity) AS QtySum
FROM Inventory
GROUP BY Item, Color WITH ROLLUP 

generates the following subtotal report:

Item                 Color                QtySum                     
-------------------- -------------------- -------------------------- 
Chair                Blue                 101.00                     
Chair                Red                  210.00                     
Chair                ALL                  311.00                     
Table                Blue                 124.00                     
Table                Red                  223.00                     
Table                ALL                  347.00                     
ALL                  ALL                  658.00   

If the ROLLUP keyword in the query is changed to CUBE, the CUBE result set is the same, except these two additional rows are returned at the end:

ALL                  Blue                 225.00                     
ALL                  Red                  433.00  

The CUBE operation generated rows for possible combinations of values from both Item and Color. For example, not only does CUBE report all possible combinations of Color values combined with the Item value Chair (Red, Blue, and Red + Blue), it also reports all possible combinations of Item values combined with the Color value Red (Chair, Table, and Chair + Table).

For each value in the columns on the right in the GROUP BY clause, the ROLLUP operation does not report all possible combinations of values from the column, or columns, on the left. For example, ROLLUP does not report all the possible combinations of Item values for each Color value.

The result set of a ROLLUP operation has functionality similar to that returned by a COMPUTE BY. However, ROLLUP has the following advantages:

  • ROLLUP returns a single result set while COMPUTE BY returns multiple result sets that increase the complexity of application code.
  • ROLLUP can be used in a server cursor while COMPUTE BY cannot.
  • The query optimizer can sometimes generate more efficient execution plans for ROLLUP than it can for COMPUTE BY.
1420 questions
0
votes
1 answer

UNMET PEER DEPENDENCY webpack when using rollup

I am trying to install 'react-dnd' and getting: +-- react-dnd@2.4.0 `-- UNMET PEER DEPENDENCY webpack@1 || 2 || ^2.1.0-beta || ^2.2.0-rc npm WARN babel-loader@6.4.1 requires a peer of webpack@1 || 2 || ^2.1.0-beta || ^2.2.0-rc but none was…
Amalin
  • 315
  • 4
  • 11
0
votes
1 answer

Calling specific data in an array created with rollup with d3.js

I'm currently working on a visualisation of shipping data and I'm trying to create a line graph where the xAxis is 00:00 to 23:59 on a specific day and the yAxis is the amount of ships at a specific minute during that day. I managed to create an…
0
votes
1 answer

Angular2 application minification and tree-shaking with Webpack

In my Angular2 application (ES6 spec), I am using WebPack with a common config which is extended in dev and prod config. In my prod config, I would like to also use uglification after doing tree shaking. How do I make it happen? Any sample/link to…
Abhi
  • 1,624
  • 2
  • 16
  • 29
0
votes
1 answer

How to configure Roll-up Babel's plugin

I have created a rollup project. I wasn't able to use rollup -c && rollup -c --environment PRODUCTION without using less than two files : rollup.config.js .babelrc Some people told me on freenode I should only have one file. I wan't to be able to…
Dimitri Kopriwa
  • 13,139
  • 27
  • 98
  • 204
0
votes
1 answer

Unable to get rollup working with an angular2 project

I am trying to get rollup setup with my ang2 project. I am unable to get past below error:- D:\js\bundling\rollup_ng2_tes1\test1>D:\js\bundling\rollup_ng2_tes1\test1\node_modules\.bin\rollup -c **? typescript.readConfigFile is not a…
Plankton
  • 388
  • 3
  • 13
0
votes
1 answer

'latLng' is not exported by 'node_modules/leaflet/dist/leaflet-src.js' Rollup build fails on leaflet

I'm using angular-seed by Minko.Also using @asymmetrik/angular2-leaflet.The normal production build works well.When running npm run build.prod.rollup.aot it fails with error. dist/tmp/app/home/demo/leaflet-d3/ping/ping-demo.component.js (23:21)…
Amal Shehu
  • 119
  • 2
  • 14
0
votes
0 answers

SQL - rollup + date condition from different tables. how to connected these two queries into one?

Im creating database for a school project and i need to write code for a couple queries. i have an issue with the one that suppose to show total revenue for the specific period of time.in my case: total revenue=total sales-total refunds. i have 4…
kaspar9
  • 31
  • 2
0
votes
0 answers

Is Angular 2 AOT compilation and tree shaking with rollup slow?

I'm going through the angular 2 deployment documentation on AOT and it recommends making copies of the JIT compilation files and maintaining the AOT and JIT files side by side. Ideally I would be able to develop with the AOT / Rollup compilation…
Ole
  • 41,793
  • 59
  • 191
  • 359
0
votes
2 answers

mysql select * from table group by id with rollup

I try to select from my table and rollup to get the Total but i failed. Here is my table and values and the result i want like this is this possible? my query : select * from mytable group by id with rollup; But my query failed to get the rollup…
Mas Harjo
  • 73
  • 9
0
votes
1 answer

How can I sum all pivot generated columns (weekends) values in the end of report

I have generated the following SQL Server pivot, and it gives me desire result. I want to add total of the all Technician jobs in a weekend columns at end of pivot (subtotal of weekend's jobs), where I'm finding it difficult. SELECT * FROM ( …
0
votes
1 answer

Oracle APEX 5: AVG in SubTotal

Using Oracle APEX 5 classic report: How do I get the average of a column in the subtotal line? I've read that a "simple" rollup function with an aggregate function for columns should do the trick - can someone please clearly describe how to do…
Tom
  • 5
  • 3
0
votes
1 answer

Create apex rollup triggers

I am looking to replace the rollups in my Salesforce rollup helper with apex versions, and run those instead. I am trying to transform the following into Apex code. Please let me know if you have any ideas.
dgelinas21
  • 641
  • 3
  • 9
  • 22
0
votes
1 answer

How to use ROLLUP and ORDER BY to generate additional TOTAL row?

I want to generate a list of all product_name(s) in the Products table as well as add an additional roll with the "total" price using ROLLUP. The "total" price is calculated by subtracting the item_price from discount then multiplying by quantity…
5120bee
  • 689
  • 1
  • 14
  • 36
0
votes
2 answers

SQL Roll Up Last 4 Week by week

I have a raw data as shown in table below. I want to get(Sum up) previous 4 weeks data.Can any one guide me how to get this by SQL Select query. Raw data table : Week Year Category Weekly Total 9 2017 Motor 8 8 …
ctee
  • 23
  • 8
0
votes
0 answers

How do I get rollup count 'Total' in table

I have created a table in the database which displays Date, User, Value. The following is a revised design: Date | User | Value ---------- | ----- | ----- So each user has a count of what submissions they have done matching via the…
TeyJohn
  • 11
  • 4