This article will introduce the oraclegroupby statement in detail and test it on an instance. For more information, see
This article will introduce the oracle group by statement in detail and test it on an instance. For more information, see
SQL code
The Code is as follows:
Create table test (a VARCHAR2 (20), B VARCHAR2 (20), c NUMBER, d VARCHAR2 (20 ))
Insert into test VALUES ('a1', 'b1', 1, 'T ');
Insert into test VALUES ('a3 ', 'b3', 3, 'T ');
Insert into test VALUES ('a4 ', 'b4', 4, 'T ');
Insert into test VALUES ('a2 ', 'b2', 2, 'T ');
Insert into test VALUES ('XX', 'XX', 5, 'x ');
Insert into test VALUES ('a1', 'b1', 1, 'T ');
Insert into test VALUES ('a3 ', 'b3', 3, 'T ');
Insert into test VALUES ('a4 ', 'b4', 4, 'T ');
Insert into test VALUES ('a2 ', 'b2', 2, 'T ');
Insert into test VALUES ('XX', 'XX', 5, 'x ');
COMMIT;
1. SELECT a, B, SUM (c) FROM test WHERE d = 't'group BY a, B order by a, B;
2. SELECT a, B, SUM (c) FROM test WHERE d = 't'group BY B, a order by a, B;
Summary:For 1, 2, the results should be the same, but the grouping order is different, and the SQL performance should be different.