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
13
votes
2 answers

is it possible to use rollup for processing just css?

I know that Rollup is used to bundle .js files. But is it possible to use it just to process css? (css, scss, less, etc). What i mean is if i had for example in my src folder (the entry folder) a file called index.css and i want rollup to precess it…
13
votes
2 answers

Export not found on module

I have a library, in one of the files i export an interface: export interface MyInterface { ... } and there is a default export, which is a react component. On an index.ts file, I import few stuff, and re-export them: import Something from…
PlayMa256
  • 6,603
  • 2
  • 34
  • 54
13
votes
1 answer

How to handle svg imports (ES6) in rollup

If I'm importing an svg file into an ES6 module, how do I handle that in rollup? I currently have something like this (simple example of what I'm doing): import next from '../assets/next.svg'; export default () => console.log('Here is some Svg: ! ',…
Maffelu
  • 2,018
  • 4
  • 24
  • 35
13
votes
2 answers

Generate typescript definition files using rollup

I am trying rollup js to build my typescript project but I don't know how to generate the definition files and how to include them automatically in the dist files. Would anyone know how to do it ? Here is my rollup.config.js import typescript from…
BkSouX
  • 739
  • 5
  • 13
  • 29
13
votes
4 answers

Replace NULL with SUBTOTAL and TOTAL in a ROLLUP

I have tried to use IFNULL to replace the NULL fields returned by ROLLUP for subtotals and totals but it doesn't appear to be working. Query: select IFNULL(usergroups.name, 'GROUP') AS DEALER, IFNULL(users.name, 'TOTAL') AS…
the_gimlet
  • 183
  • 1
  • 2
  • 7
12
votes
4 answers

How can I find rollup 3.1.0 update error?

i want to install rollup-plugin-visualizer but its need to update rollup. updated rollup from 1.8.0 to 3.1.0 got error [!] RollupError: Node tried to load your configuration file as CommonJS even though it is likely an ES module. To resolve this,…
Garo Gabrielyan
  • 466
  • 2
  • 7
  • 20
12
votes
1 answer

Vite library mode vs rollup

Vite has revolutionised web development for frontend js/ts apps. As it is based on rollup and supports library mode, I wonder if there is still any advantage building js libraries directly with rollup or shall I use vite instead? Vite hides…
husayt
  • 14,553
  • 8
  • 53
  • 81
12
votes
2 answers

how to force vite clearing cache in vue3

I have a side project with Vue.js 3 and vite as my bundler. After each build the bundled files got the same hash from the build before, like: index.432c7f2f.js <-- the hash will be identical after each new…
wittgenstein
  • 3,670
  • 7
  • 24
  • 41
12
votes
2 answers

Output multiple files using Rollup

I am using Rollup to bundle my code for production. I have multiple js files, so I am using the Rollup plugin-multi-entry plugin to use a glob pattern to target all of my js files. I am outputting the files in umd format. Currently they are being…
Jonny
  • 1,053
  • 1
  • 13
  • 26
12
votes
4 answers

Output Single HTML File from Svelte Project

I can't find any example anywhere online that shows how to (or if we can) output a single HTML file from a Svelte project using Rollup (not Webpack), containing all CSS and JS injected inline (and not as URLs in script).
Sammy
  • 3,395
  • 7
  • 49
  • 95
12
votes
1 answer

How do I get Socket.io working with Svelte?

I'm trying to get socket.io working with Svelte that I've recently started experimenting with, which is in its stock form as installed by the instructions given at https://svelte.dev/. I'm at a loss as to why I'm getting bundle.js:4497 GET…
MikeyB
  • 460
  • 1
  • 6
  • 22
12
votes
3 answers

Questions about Postgres track_commit_timestamp (pg_xact_commit_timestamp)

I'm working on a design for a concurrency-safe incremental aggregate rollup system,and track_commit_timestamp (pg_xact_commit_timestamp) sounds perfect. But I've found very little commentary on it generally, and couldn't figure out how it works in…
Morris de Oryx
  • 1,857
  • 10
  • 28
11
votes
0 answers

Single SPA + Vite - Cannot use import statement outside a module

I am using Typescript + Vite + Single SPA Just trying to replicate the https://github.com/joeldenning/vite-single-spa-example and https://github.com/joeldenning/vite-single-spa-root-config. Hence, in my index.ejs I have
Eduardo Sousa
  • 875
  • 10
  • 22
11
votes
0 answers

Rollup + Svelte + typescript : couldn't use rollup-plugin-import-alias

compatbility between some useful rollup plugins (typescript, import-alias, svelte) please read below installation details setup steps : rollup-plugin-import-alias rollup-plugin-typescript2 rollup-plugin-svelte Hi, could build properly the rollup…
Hefeust
  • 501
  • 1
  • 5
  • 14
11
votes
1 answer

Using Rollup for a React Component Library

I am beginning to learn a bit about bundling as I am working on updating a small, internal React component library which uses Rollup. Current State Right now, all of the components are being bundled down into one index.js files. And whenever I…
Yuschick
  • 2,642
  • 7
  • 32
  • 45
1 2
3
94 95