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
10
votes
5 answers

The requested module '/node_modules/.vite/deps/vue.js' does not provide an export named 'default'

The following is my problem. I packaged my project through vite in library mode. The error occurs whenever my library includes any third party UI library (e.g vue-loading-overlay). But other libraries like moment.js will have no problem. This is my…
JoeH
  • 368
  • 1
  • 3
  • 9
10
votes
1 answer

Rollup & React- How to separate component bundles?

I currently am trying to build a UI Library for React and I am having a little bit of trouble. Currently I am using typescript and rollup, and I am able to bundle a single index.js and I am able to import those components but it is importing the…
codebytesfl
  • 198
  • 1
  • 8
10
votes
2 answers

Is there a way to simulate GROUP BY WITH CUBE in MySql?

MySql supports GROUP BY WITH ROLLUP which will return aggregates for the last x of the n columns in the group by but does not support GROUP BY WITH CUBE to take all combinations of the n columns and take aggregates. I can simulate this by doing…
Charles Chen
  • 101
  • 1
  • 1
  • 3
10
votes
1 answer

Plugin typescript: @rollup/plugin-typescript TS2307: Cannot find module './App.svelte' or its corresponding type declarations

I have the following problem with my svelte project main.ts import App from './App.svelte'; const app = new App({ target: document.body, }); export default app; The first line return a warning Plugin typescript: @rollup/plugin-typescript…
Bobby
  • 4,372
  • 8
  • 47
  • 103
10
votes
1 answer

why do we still need module bundlers when we have native ESM support in browsers now

why do developers still need to use module bundlers like rollup and webpack when browsers now support native ESM
10
votes
1 answer

Svelte: imported TypeScript files not recognized

I am trying to build an app with Svelte and TypeScript using Rollup and when I try to build my Svelte components I just can't seem to make it compile my .ts files that are included from a .svelte component. I keep getting this error: [!] Error:…
Tokimon
  • 4,072
  • 1
  • 20
  • 26
10
votes
2 answers

How to remove comments when building TypeScript into JavaScripts using rollup

I am using rollup to build my TypeScript sources. I want to remove comments ONLY, without any minification, in order to hot update code when debugging. I have tried rollup-plugin-terser, it can remove comments but it will also minify my code…
Summer Sun
  • 947
  • 13
  • 33
10
votes
2 answers

Tree-shaking with rollup

I have a project in which I bundle a components library using Rollup (generating a bundle.esm.js file). These components are then used in another project, that generates web pages which use these components - each page is using different…
Luoruize
  • 579
  • 2
  • 7
  • 25
10
votes
1 answer

Should main, module, browser properties of package.json point to minified or source?

For a JS library which is published in a structure like ... my-package\ dist\ my-package.cjs.js my-package.cjs.min.js my-package.cjs.min.js.map my-package.esm.js my-package.esm.min.js my-package.esm.min.js.map …
Josh M.
  • 26,437
  • 24
  • 119
  • 200
10
votes
1 answer

Uncaught TypeError: this.method is not a function - Node js class export

I am new to node.js and I am trying to require a class. I have used https://developer.mozilla.org/en/docs/Web/JavaScript/Reference/Classes as reference. However, when I do this for example: // talker.js class Talker { talk(msg) { …
CUGreen
  • 3,066
  • 2
  • 13
  • 22
10
votes
2 answers

oracle rollup function with multiple columns

I've a simple query: WITH data(val1, val2, val3) AS ( SELECT 'a' ,'a-details' ,'1' FROM DUAL UNION ALL SELECT 'b' ,'b-details' ,'2' FROM DUAL UNION ALL SELECT 'c' ,'c-details' ,'3' FROM DUAL ) SELECT NVL(val1,'Total…
ajmalmhd04
  • 2,582
  • 6
  • 23
  • 41
9
votes
2 answers

How can I replace NULL category titles in MySQL ROLLUP function?

Using the MySQL query below, I have created a pivot table which is pretty much exactly what I am looking for. I would however like to replace the NULL values with actual descriptions, such as SubTotal and GrandTotal. Here is the pivot table format…
Andrew
  • 497
  • 1
  • 6
  • 18
9
votes
2 answers

Why does Rollup complain about code-splitting when I am not code-splitting?

With only one output entry in my rollup.config.js like so: export default { input: './src/Index.tsx', output: { dir: './myBundle/bundle', format: 'iife', sourcemap: true, }, plugins: [ typescript(), nodeResolve(), …
Langostino
  • 121
  • 2
  • 5
9
votes
1 answer

Nrwl / Nx - how to build single js file consumable by browser with dependencies bundled

I need to build a single js that can be used as Service Worker. I have a nrwl workspace with two @nrwl/web:lib packages, one is common and the other is worker. The worker package uses common through import { stuff } from @my/common. With library…
František Žiačik
  • 7,511
  • 1
  • 34
  • 59
9
votes
1 answer

Error could not resolve entry module (watch) - Rollup

This is my first attempt at trying to understand/use rollup. I am using this boilerplate as it is all based around three.js which I also enjoy working with. My current (almost certainly incorrect) method thus far has been: Download boilerplate…
704
  • 287
  • 2
  • 3
  • 12