Professional Documents
Culture Documents
Step 4: The GROUP BY Clause Is Applied To Partition The Rows Into Groups. at
Step 4: The GROUP BY Clause Is Applied To Partition The Rows Into Groups. at
Step 4: The GROUP BY Clause Is Applied To Partition The Rows Into Groups. at
Note: If a column appears in the select list, it must also appear in the
GROUP BY clause. However, the opposite is not necessarily true; if a column
appears in the GROUP BY clause it does not necessarily have to appear in the
select list. A GROUP BY clause often guarantees that the final result set will con-
tain no duplicate rows, but this is not necessarily the case if a column named in
the GROUP BY clause is omitted from the select list.
If there is no GROUP BY clause, each row in the candidate result set is treated
as a separate group.
In the end, each group will be reduced to a single row, but that cant happen
until later. Heres what the groups look like at this point, after the GROUP BY
t1.key_1, t3.key_1 process has finished:
t1. t1. t2. t2. t3. t3.
key_1 non_key_1 key_1 key_2 key_1 non_key_1 a b
===== ========= ===== ===== ===== ========= === ====
A 1 1 NULL NULL 3 333 100 3000 -- Group 1
-----------------------------------------------------------
B 1 1 NULL NULL 4 333 100 4000 -- Group 2
-----------------------------------------------------------
E 2 2 2 21 3 333 200 3000 -- Group 3
F 2 2 2 22 3 333 200 3000
G 2 2 2 23 3 333 200 3000
-----------------------------------------------------------
H 2 2 2 21 4 333 200 4000 -- Group 4
I 2 2 2 22 4 333 200 4000
J 2 2 2 23 4 333 200 4000