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
7
votes
1 answer

Rollup wants me to create global variables. How can I use 'export default'?

I have a small app I am converting to use rollup. It uses ES6 modules - when I run rollup -c, it complains about one of my ES6 modules: /js/monogram.js (imported by src\main.js) (!) Missing global variable name Use output.globals to specify browser…
mikemaccana
  • 110,530
  • 99
  • 389
  • 494
7
votes
2 answers

How to use css @import in rollup?

I try to create a simple rollup app's config and have some troubles with css. This is my css file: @import "normalize.css"; @import "typeface-roboto"; html, body, #root { height: 100%; font-family: Roboto, serif; } body { background:…
pashaigood
  • 111
  • 1
  • 1
  • 5
7
votes
1 answer

RollupJS - JavaScript heap out of memory

I know I have a lot of imports of .js files that are data (400K lines) so I suspect that is the problem. Anything that I can do about this? workbench@1.0.0 build D:\wwwroot\Workbench rollup -c scripts/Main.js → bundle.js... <--- Last few GCs…
Dr.YSG
  • 7,171
  • 22
  • 81
  • 139
7
votes
0 answers

Rollup.js, Typescript and require()

I'm trying to require an untyped module config // rollup.config.js import typescript from 'rollup-plugin-typescript2'; import commonjs from 'rollup-plugin-commonjs'; import nodeResolve from 'rollup-plugin-node-resolve' export default { input:…
psx
  • 1,315
  • 2
  • 10
  • 12
7
votes
1 answer

Can't import npm modules in commonjs with rollup : "require is not defined"

I work on an ES6 project that I transpile using rollup and babel. It works well except when I try to import npm modules that use commonjs (and particularly require('something')) getting an error "require is not defined" in my browser (which means it…
Arthur Pesah
  • 235
  • 2
  • 9
7
votes
2 answers

How to preserve custom component tag names in Vue.js

I'm using Vue's single-file component spec (*.vue) for custom components in my application. Together with rollup and rollup-plugin-vue, I have observed the output in the DOM, for custom components I have written, to be composed of the equivalent…
WoodyWoodsta
  • 160
  • 2
  • 15
7
votes
4 answers

How to set as external all node modules in rollup?

I want to have all modules imported from node_modules as external. What is the configuration for this? I tried without success : import path from "path"; import glob from "glob"; import multiEntry from "rollup-plugin-multi-entry"; export default { …
Troopers
  • 5,127
  • 1
  • 37
  • 64
7
votes
2 answers

SQL SERVER T-SQL Calculate SubTotal and Total by group

I am trying to add subtotal by group and total to a table. I've recreated the data using the following sample. DECLARE @Sales TABLE( CustomerName VARCHAR(20), LegalID VARCHAR(20), Employee VARCHAR(20), DocDate DATE, …
alejandro zuleta
  • 13,962
  • 3
  • 28
  • 48
6
votes
1 answer

Rollup build issue always says cannot find module node:process

I am facing issue tried many things including changing node versions, removing node_modules and re-installing all dependencies but still not found any solution. I need help to solve this issue . I want to create a library but stuck here . Error when…
Muzamil Abbas
  • 692
  • 8
  • 16
6
votes
0 answers

Dynamic lazy imports not working on production, using Vite

I want to to dynamically import several mdx files into a react component, e.g. I have a page that requires different mdx files depending on the selected language, so only one specific file is loaded at a time: React component: import { lazy } from…
Mark Hkr
  • 620
  • 2
  • 7
  • 15
6
votes
1 answer

React component library, how to correctly bundle fonts with rollup

I'm working on a project which has a React component library, and a Next JS app which imports said library. I've read a lot of questions on SO and attempted most of the solutions to no avail. We have the component library working, fonts and all, and…
Jamadan
  • 2,223
  • 2
  • 16
  • 25
6
votes
0 answers

Rollup failed to resolve import "src/bootstrap.tsx" from "index.html"

The problem : This is what happens when i run the build with my React/Vite app : vite v2.9.6 building for production... ✓ 1 modules transformed. ERROR [vite]: Rollup failed to resolve import "src/bootstrap.tsx" from "index.html". This is most…
Caroline.S
  • 69
  • 1
  • 4
6
votes
2 answers

Vue + Vite + Rollup: Dynamic import not working on production build

I'm trying to use Vite with dynamic-import Vue SFCs, but it does not work on production build. There is stackblitz example: https://stackblitz.com/edit/vitejs-vite-ant1g2?file=src/main.ts Test command and localhost:3000 shows good. vite However…
tamaina
  • 79
  • 1
  • 7
6
votes
1 answer

Rollup.js can not detect default exports when trying to build component library with React.js

I am trying to create component library with React.js, I am using Rollup.js for this. When I am building the app, I see this error in the console. It seems Rollup can not detect default exports, I tried to add a .babelrc file configuration but…
Nightcrawler
  • 943
  • 1
  • 11
  • 32
6
votes
0 answers

Rollup bundling peer dependencies / Multiple instances of MUI make the ThemeProvider not work

I have two different repos I'm working on, lib and apps. lib has some React components made with MUI that I want to consume in apps, and that's built with Rollup. apps is a Lerna monorepo with a Next.js app that imports lib as a dependency to…
Danziger
  • 19,628
  • 4
  • 53
  • 83