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

Web workers inside a JS library with Rollup

I am building a negamax engine in Typescript that uses Thread.js web-workers. It is a npm library that will be imported by an application built using webpack. I am using Rollup to build the engine - how can I export the web-worker files so they are…
Shukant Pal
  • 706
  • 6
  • 19
9
votes
1 answer

SCSS alias in Vue SFC via Rollup

When using Webpack is pretty straight forward to add an alias for scss files in a Vue SFC, e.g: Would be the following in Webpack: alias: { sass: path.resolve(__dirname,…
Jamie Halvorson
  • 338
  • 3
  • 11
9
votes
0 answers

Rollup with React vendor splitting

I'm experimenting with using Rollup as a React toolset. I've got a working prototype when I can use lazy loading in react. I'm just working with just ES6 Modules, I'll integrate SystemJS for older browsers later. My question is regarding the rollup…
sansSpoon
  • 2,115
  • 2
  • 24
  • 43
9
votes
0 answers

How to process css/scss from a specific .scss file (and not entry.js) using rollup

I'm currently using Rollup and PostCSS. How do I target a specific scss file that I want to be processed rather than having to use @import 'source/scss/main.scss'in mysource/js/entry.js` For example doing something like... //…
dwkns
  • 2,369
  • 4
  • 22
  • 35
9
votes
2 answers

Resolve woff imports with Rollup

I am attempting to bundle a theme package using Rollup.js. The theme includes some global styles, most relevant @font-face. I am importing my fonts and with the intent to inject them via styled-components injectGlobal. When I try to bundle the…
Jeffpowrs
  • 4,430
  • 4
  • 30
  • 49
9
votes
3 answers

AOT & Roll-Up: Only bundles main.js and nothing else

I am trying to implement AOT and Rollup per https://angular.io/docs/ts/latest/cookbook/aot-compiler.html#!#tree-shaking I run rollup per:"node_modules/.bin/rollup" -c scripts/rollup-config.js and the result is a build.js file with just the entry…
Ques Tion
  • 3,365
  • 2
  • 11
  • 10
9
votes
1 answer

Error: Illegal reassignment to import

I am trying to import a module into a typescript file and then bundle with Rollup.js. But I am getting an error message which prevents Rollup from completing. The import: import * as mapboxgl from 'mapbox-gl'; (mapboxgl as any).accessToken =…
Michael Wilson
  • 1,548
  • 3
  • 21
  • 44
8
votes
1 answer

Unexpected character '@' (Note that you need plugins to import files that are not JavaScript) when I use scss in rollup

When I use Scss in rollup, and When I build project then there is a error: [!] Error: Unexpected character '@' (Note that you need plugins to import files that are not JavaScript) components/styles/index.scss (3:0) 1: @import 'variables'; I tried…
Ha0ran
  • 585
  • 5
  • 13
8
votes
0 answers

How to include a font inside my npm package

I'm trying to create my first npm package now. I'm using rollup and I test it inside another create-react-app using npm link. I want to use a certain google font on my component's text, but it seems like importing it inside the package files isn't…
Niv Kor
  • 182
  • 1
  • 9
8
votes
0 answers

Rollup'd react component css styles aren't being added to SSR document in NextJS

I've made a small npm package that exports a single component. The component is styled using SCSS modules, and bundled together using Rollup. It all seemed to work fine, but once I imported it into a NextJS project I noticed that the styles aren't…
user1877760
  • 263
  • 2
  • 9
8
votes
2 answers

How to include HTML partials using Vite?

Is it possible to include snippets of shared HTML using Vite (vanilla)? I'm looking for a way to have the HTML prerendered without injecting via JS. Something like: { include 'meta-tags' } { include 'nav'…
docta_faustus
  • 2,383
  • 4
  • 30
  • 47
8
votes
1 answer

Why bundle NPM packages if they will be bundled by consuming project?

I’m building a TypeScript package to be published on NPM. I’ll be consuming this package in future web development projects likely using Vite. When I build a future website with this module, does it matter if it’s already bundled? Won’t Rollup (used…
Ben Stickley
  • 1,551
  • 1
  • 16
  • 22
8
votes
1 answer

jprofiler or other: how do I roll up recursive method calls?

I have a long operation that I want to profile in JProfiler (or other suggestions), but the method is very recursive, so the tree view in CPU View doesn't help very much. It shows me CPU times like this: beginOperation 100% |- recursiveMethod 99% |…
Sean Adkinson
  • 8,425
  • 3
  • 45
  • 64
8
votes
3 answers

'rollup' is not recognized as an internal or external command

I would like to ask if how should I fix this issue because I am already stuck and confused about this part. I already installed rollup globally using this command npm install --global rollup However when I tried to run the 'rollup' command then I…
cdt
  • 135
  • 1
  • 1
  • 9
8
votes
0 answers

Babel TypeScript preset doesn't understand import type and export type

I'm trying to build my npm package, but getting this error: Error: Unexpected token (Note that you need plugins to import files that are not JavaScript) I'm not sure if it's coming from rollup or babel. The code it's complaining about: export type…
Steve
  • 8,066
  • 11
  • 70
  • 112