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
3 answers

Is there a simple tool or a library for “rolling up” a set of events with timestamps into a count of events in each time window of a given span?

My specific problem is that I have a set of Apache access logs, and I want to extract from them a “rolled up” count of requests by grouping them into a set of time windows of a specified time. Example of my data: 127.0.0.1 - - [01/Dec/2011:00:00:11…
Avi Flax
  • 50,872
  • 9
  • 47
  • 64
-1
votes
0 answers

"randomUUID" is not exported by "__vite-browser-external", #14210

Describe the bug npm run build is failing with Error: "randomUUID" is not exported by "__vite-browser-external" Here is my vite.config.ts import { defineConfig } from 'vite' import react from '@vitejs/plugin-react' import { crx } from…
ishandutta2007
  • 16,676
  • 16
  • 93
  • 129
-1
votes
1 answer

Copying and transforming a file

I'm working with an Office.js add-in that accepts manifest.xml file to specify add-in information. I have created a template for it named manifest_template.xml and injected some variables in it. This file needs to be copied (to the same folder with…
dotNET
  • 33,414
  • 24
  • 162
  • 251
-1
votes
1 answer

package.json exports for individual modules

What is the correct way to export from a package.json file, such that: some-file.ts import { someAmazingFunction } from '@my-org/package/amazing" i.e., we can import from a specific "sub-module" (I'll call it a sub-module, but please correct me if…
Micheal J. Roberts
  • 3,735
  • 4
  • 37
  • 76
-1
votes
0 answers

How can I get rollup to bundle images into my build

I'm building a multi-page typescript webapp using open-WC as the base, which came with rollup as the default build tool. We have a handful of assets included in our application and I'm having trouble getting them into the actual dist folder without…
ChickenWing
  • 639
  • 9
  • 24
-1
votes
1 answer

Rollup modules but keep all variables global

I will simplify code for my problem. So let's assume I have in module1.js export class MyClass { }; and in index.js import { MyClass } from './module1.js' var X = MyClass(); Next i want to bundle index.js with rollup in such way that the result…
-1
votes
1 answer

The js file builded by Rollup can't give the right order

I create a typescript project and use Rollup to build it, but error: and then I find this bug in the builded file carefully, and discover the class Text has defined before class Carobj var newcar = (function (exports){ // ...... class Text…
Acbox Sky
  • 3
  • 2
-1
votes
1 answer

How to import index.vue files without specifying the file name using vue 3 and vite?

I started working recently on a Vue 3 application which runs with vite and I am trying to restructure the directories so that I can group components and related sub-components in folders. I am currently using /path/to/MyComponent/index.vue to import…
InCodice
  • 1
  • 2
-1
votes
1 answer

MySQL Rollup format

How do I format the "total" row of a rollup? Backgroup I have a MySQL select statement that is using group by with rollup it works however, for formatting reasons I need to identify what row is a "detail" and what row is a "total." Doing this by a…
Xaphann
  • 3,195
  • 10
  • 42
  • 70
-1
votes
1 answer

What is the right way to ship css in a react library?

I am developing my own library of react components. I am using rollup to create the build. I also want to ship css along with it which i bundled into a single styles.css file. My concern is how a user would use it. They can simply import the…
-1
votes
2 answers

How to import Svelte library written in TypeScript

EDIT: This question is outdated. As of 12.8.2022, svelte-kit package https://kit.svelte.dev/docs/packaging, is the recommended option. I created a library (https://github.com/TeemuKoivisto/svelte-tree-view) which I import in another project as a…
TeemuK
  • 2,095
  • 1
  • 18
  • 17
-1
votes
2 answers

Invalid in the select list because it is not contained in either an aggregate function (with union and rollup)

i have query like below select COALESCE(Funding_Type, 'Total') as Funding, nama as nama1, sum(total) as Revenue from (select ('NDIS') as Funding_Type, business_name as nama, sum(total_amount) as total from invoices a inner join …
ryan
  • 53
  • 6
-1
votes
1 answer

SQL groupby rollup vs union

Sql question: enter image description here competitor country Acme Corp USA GLOBEX USA Openmedia France K-bam USA Hatdrill UK Hexgreen Germany D-ranron France Faxla Spain the output should be country competitors France 2 Germany…
-1
votes
1 answer

How to import local file system path instead of node_module in Rollup?

For some reason, I have to write code like this: import { something } from '/Users/my-user-name/my-working-dir/my-package/src/somefile.ts'; Rollup sees /Users thinks that's a node_modules, but not. I can't find any rollup plugin related to…
Joseph
  • 3,974
  • 7
  • 34
  • 67
-1
votes
1 answer

Recursion? How can I group orders by common items

The setup is this. I have Orders and OrderDetails and the OrderDetails have an Item Number. Orders have many OrderDetails. Out of ~1000 Orders with ~10,000 OrderDetail lines, I need the Top 16 Orders that have the most Items in common. After a…
James
  • 1
  • 2
1 2 3
94
95