nerdexam
Oracle

1Z0-071 · Question #444

Examine this partial query: Examine this output: Which GROUP BY clause must be added so the query returns the results shown?

The correct answer is B. GROUP BY ch.channel_type, t.month, ROLLUP(co.country_code). See the full explanation below for the reasoning.

Question

Examine this partial query:

Examine this output:

Which GROUP BY clause must be added so the query returns the results shown?

Exhibits

1Z0-071 question #444 exhibit 1
1Z0-071 question #444 exhibit 2

Options

  • AGROUP BY ch.channel_type, ROLLUP(t.month, co.country_code);
  • BGROUP BY ch.channel_type, t.month, ROLLUP(co.country_code);
  • CGROUP BY CUBE(ch.channel_type, t.month, co.country_code);
  • DGROUP BY ch.channel_type, t.month, co.country_code;

How the community answered

(44 responses)
  • A
    5% (2)
  • B
    82% (36)
  • C
    11% (5)
  • D
    2% (1)

Community Discussion

8
Prof. SaraProf. SaraMay 19, 2026

The correct answer is B. The output shows NULL appearing only in the country_code column, which tells you the rollup is happening at the country level alone, producing a subtotal row for each channel_type and month combination with country_code collapsed. Option A puts both t.month and co.country_code inside ROLLUP, which would also generate a NULL for month, giving you an extra level of aggregation you do not see in the output. Option C uses CUBE, and CUBE generates every possible combination of subtotals across all three columns, producing far more NULL-filled rows than what is displayed. Remember the mnemonic ROLLUP rolls from right to left inside its parentheses, so ROLLUP(co.country_code) adds exactly one extra row per group, the subtotal where country_code is NULL, which matches the output precisely.

25
Wesley A.Wesley A.May 20, 2026

The move that saved me on attempt two was counting distinct NULL patterns in the result set before even glancing at the answer choices, because each unique NULL combination maps to exactly one aggregation level, and that count alone eliminates A and C immediately.

0
Wesley A.Wesley A.May 27, 2026

B is right, and I got burned on a question almost identical to this my first attempt because I kept thinking ROLLUP rolls up everything to the left, when it only rolls up what is inside the parentheses. The trap with A is that wrapping both t.month and co.country_code inside ROLLUP gives you an extra level of subtotals you do not see in the output, which should have been my clue. Quick question though, when you look at the NULL rows in the output, can you tell exactly which column is NULL and whether there is one NULL row per month-channel combo or one grand total NULL at the very end, because that is what tells you how deep the rollup goes?

5
Prof. SaraProf. SaraMay 28, 2026

The quickest read is to count the distinct NULL patterns in the result, because ROLLUP(a, b) produces nulls-in-b-only for each subtotal group plus nulls-in-both for the single grand total, so if you see only one all-NULL row with no per-month channel subtotals, that is your confirmation that only one column was inside the ROLLUP, not two.

0
Marisol N.Marisol N.May 27, 2026

B is correct because placing ROLLUP only around co.country_code generates a subtotal row per channel_type and month combination with country_code set to NULL, which matches exactly the output shown without collapsing the channel_type or month groupings the way CUBE in option C would. On the 1Z0-071 exam under the "Restricting and Sorting Data / Group Functions" objective, remember this hook: ROLLUP rolls up from right to left, so wrap only the columns whose subtotals you need, not the anchor columns you want to keep fixed.

5
Prof. SaraProf. SaraMay 28, 2026

Solid breakdown, and a quick count check to add: ROLLUP with n expressions always produces exactly n+1 grouping levels including the grand total, so when the exam shows an output table with only two subtotal tiers, you can eliminate CUBE immediately because CUBE generates 2^n combinations and would have produced four levels there, not two.

0
Bao N.Bao N.Jun 7, 2026

Saw this one and went straight for A because the output had those subtotal rows and I figured ROLLUP on both month and country made sense, but that was wrong. When I actually traced the output rows carefully, the channel_type and month columns never showed nulls for subtotals, meaning those two were fixed grouping columns and only country_code was rolling up. That pattern is exactly what GROUP BY ch.channel_type, t.month, ROLLUP(co.country_code) produces, where you get a detail row per country plus a subtotal row per channel/month combo with country_code as null. B is the only option that locks channel_type and month as stable dimensions while letting ROLLUP do its thing on just the country level.

2
Dragan P.Dragan P.Jun 8, 2026

Saw that output with NULLs only in country_code and my eye jumped straight to A, figuring the ROLLUP wrapped both month and country_code since the subtotal rows seemed to aggregate across those two. What snapped me out of it was counting the NULL pattern carefully: channel_type and month stay populated on every subtotal row, only country_code goes NULL, which tells you the rollup boundary is sitting exclusively around country_code, exactly what B gives you with ROLLUP(co.country_code) tacked on after the two flat columns.

-1
Full 1Z0-071 Practice