A silver sales table must be summarized into a gold table with total revenue and order count per store per day. Which two approaches produce it? (Select TWO.)
- Exam domain
- Ingest and transform data30–35% of the exam
- Difficulty
- Easy
- In this mock
- 22 questions on this domainPractise this domain
Why the exam asks this
Ingest and transform data: Ingest and transform batch data.
Objective in the exam guide: Group and aggregate data.
Aggregated gold tables make reports fast. The exam checks you can write the aggregation in more than one engine.
Why D and E are the answers
A multiple-response question. Choose two. There is no credit for picking only some of them.
PySpark: df.groupBy("store_id", "order_date").agg(sum("amount"), count("order_id"))
T-SQL: SELECT store_id, order_date, SUM(amount), COUNT(order_id) FROM sales GROUP BY store_id, order_date
Both group rows by store and date and aggregate them: groupBy with agg in PySpark, GROUP BY with SUM and COUNT in T-SQL.
How it works
Grouping collects rows that share key values, such as store and date.
Aggregate functions, such as sum and count, compute one value per group.
PySpark uses groupBy().agg(); T-SQL uses GROUP BY with aggregate functions.
Clues in the question
The words that point to the answer, and what each one tells you.
- Per store per day
- Group by store_id and order_date.
- Total revenue and order count
- SUM and COUNT.
In detail
- Choose the engine your team uses; both produce the same result.
- Write the result as a gold Delta table or warehouse table.
Side by side with look-alikes
| Engine | Aggregation syntax |
|---|---|
| PySpark | groupBy(...).agg(sum(...), count(...)) |
| T-SQL | GROUP BY ... with SUM() and COUNT() |
| KQL | summarize sum(...), count() by ... |
| Dataflow Gen2 | Group by step |
Every option, checked
Knowing why each wrong option fails is how you rule it out on exam day.
A. PySpark: df.dropDuplicates(["store_id"])WrongMost tempting
This keeps one row per store and loses all totals.
Why it tempts: It produces one row per store, which looks like a summary. But it keeps an arbitrary row and computes no totals.
B. T-SQL: SELECT TOP 100 * FROM sales ORDER BY amount DESCWrong
This returns the largest orders, not totals.
C. PySpark: df.select("store_id").distinct()Wrong
This lists stores without any totals.
D. PySpark: df.groupBy("store_id", "order_date").agg(sum("amount"), count("order_id"))Right
Both group rows by store and date and aggregate them: groupBy with agg in PySpark, GROUP BY with SUM and COUNT in T-SQL.
E. T-SQL: SELECT store_id, order_date, SUM(amount), COUNT(order_id) FROM sales GROUP BY store_id, order_dateRight
Both group rows by store and date and aggregate them: groupBy with agg in PySpark, GROUP BY with SUM and COUNT in T-SQL.
In practice
- Aggregate incrementally: recompute only the dates that received new rows.