Question 2 MCQ · 3.0 marks
Consider the table **Champions_League** for given subquestions
Published solution
**Answer: A**
**Topic:** SQL Queries — *Grouping by Multiple Columns (GROUP BY Goals, Team)*
### Step-by-Step Solution
**Step 1:** Inspect the resultant Table 2 (`Result`) with columns `Goals`, `Team`, and `Count`:
- Notice that `Barcelona` appears in **two separate rows**: once for `Goals = 20` (`Count = 2`: De Jong, Araujo) and once for `Goals = 12` (`Count = 1`: Cubarsi).
- Similarly, `PSG` appears in **two separate rows**: once for `Goals = 16` (`Count = 1`: Mbappe) and once for `Goals = 14` (`Count = 1`: Dembele).
**Step 2:** This means the rows of `Champions_League` are grouped by the pair **`(Goals, Team)`** (`GROUP BY Goals, Team`) and counted via `COUNT(*)`:
`SELECT Goals, Team, COUNT(*) FROM Champions_League GROUP BY Goals, Team;`
**Step 3:** This matches Option **A**.
**Key Takeaway / Tip:** When the `SELECT` clause projects non-aggregated columns `Goals` and `Team` alongside `COUNT(*)`, both `Goals` and `Team` must appear in the `GROUP BY` clause.
A: **Correct:** Option A (
Source diagram or notation unavailable. Please report this question for correction.) matches our derived result under Grouping by Multiple Columns (GROUP BY Goals, Team). When the `SELECT` clause projects non-aggregated columns `Goals` and `Team` alongside `COUNT(*)`, both `Goals` and `Team` must appear in the `GROUP BY` clause.
B: **Incorrect:** Option B (
Source diagram or notation unavailable. Please report this question for correction.) does not satisfy the conditions derived in the step-by-step analysis for Grouping by Multiple Columns (GROUP BY Goals, Team) (correct choice: A).
C: **Incorrect:** Option C (
Source diagram or notation unavailable. Please report this question for correction.) does not satisfy the conditions derived in the step-by-step analysis for Grouping by Multiple Columns (GROUP BY Goals, Team) (correct choice: A).
D: **Incorrect:** Option D (
Source diagram or notation unavailable. Please report this question for correction.) does not satisfy the conditions derived in the step-by-step analysis for Grouping by Multiple Columns (GROUP BY Goals, Team) (correct choice: A).