Select A, B, C, D, E, the from emp
Group by A rollup (A, B), (C, D), E is similar to the said such A sentence what mean?? Pray god give directions!!!!!!!!!!
CodePudding user response:
Is a total line, you can do some data, test;CodePudding user response:
SQL>
SQL> Create table test (
2 a varchar (10),
3 b varchar (10),
4 c varchar (10),
5 d varchar (10),
6 e int,
7 f int
8);
The Table created
SQL> The begin
2 insert into the test values (A1, B1, C1, 'D1, 100, 100);
3 the insert into the test values (' A1 ', 'B2, C1, D1, 200, 200);
4 the insert into the test values (' A2 ', 'B1, C1, D1, 300, 100);
5 the end;
6/
PL/SQL procedure successfully completed
SQL> Select a, b, c, d, the sum (e), sum (f) from the test group by rollup (a, b), c, d;
A B C D SUM (E) the SUM (F)
-- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- --
A1 B1 C1 100 D1-100 A1, B1 summary
A1 B2 C1 200 D1-200 A1, B2 summary
A1 C1 300 D1-300 A1 summary
A2 B1 C1 D1, 300, 100 - A2, B1 summary
A2 C1 D1, 300, 100 - A2 summary
C1 D1 line 600-400 total combined
6 rows selected
SQL> Drop table test purge;
Table dropped
SQL>
CodePudding user response:
http://blog.itpub.net/519536/viewspace-610995/Very good,
CodePudding user response:
Group by A rollup (A, B)The grouping species: three;
The first: group by A, B
The second: group by A
The third: group by NULL
(note: this is no group by the NULL method, in this case is to facilitate, and use, the meaning is: there is no group, that is all to do a statistical data, such as the aggregation function is the SUM, that is to SUM all meet the conditions of data, the meaning of this writing)
Result set: for the above three kinds of grouping statistics of the result set and set and remove duplicate data,
Group by A rollup (A, B, C)
The grouping species: four;
The first: group by A, B, C
The second: group by A, B
The third: group by A
Fourth: group by NULL
CodePudding user response:
After the grouping statistics,CodePudding user response:
Is after the grouping statistics has A summary statistics, such as Group by rollup (A, B)A and B of the same record summary first, then the same A record summary again and the last is to all the data summary