The effect of rollup is to count the name of a grouped column after group by.
BankID as the first column
SELECT Case -grouping (Branchid) = 0 Then branchid ELSE ' subtotal ' END as Branchid, case When grouping (bankid) = 0 Then bankid ELSE ' Total ' END as BankID, SUM (balance) from ebanksummwhere< c12/>workdate = ' 20140320 ' GROUP by BankID, Branchid with rollup
Branchid as the first column
SELECT Case -grouping (Branchid) = 0 Then branchid ELSE ' subtotal ' END as Branchid, case< C22/>when grouping (BankID) = 0 Then bankid ELSE ' Total ' END as BankID, SUM (balance) from Ebanksummwhere workdate = ' 20140321 ' GROUP by Branchid, BankID with rollup
The cube function counts all the columns that follow the groupby. The difference between a and rollup is the column to be counted. Rollup counts only one column, and cube counts all columns
SELECT Case -grouping (Branchid) = 0 Then branchid ELSE ' subtotal ' END as Branchid, case When grouping (bankid) = 0 Then bankid ELSE ' Total ' END as BankID, SUM (balance) from ebanksummwhere< c12/>workdate = ' 20140321 ' GROUP by BankID, Branchid with Cube
The rollup and cube functions of DB2