A dashboard must show, for each day, the average sales of that day and the six days before it. What is this calculation?
- Exam domain
- Data Operations and Support22% of the exam
- Difficulty
- Easy
- In this mock
- 21 questions on this domainPractise this domain
Why the exam asks this
Task Statement 3.2: Analyze data by using AWS services.
Objective in the exam guide: Define data aggregation, rolling average, grouping, and pivoting.
These are the everyday building blocks of analytical SQL. Naming and writing them correctly is expected of any data engineer.
Why D is the answer
A seven-day rolling average, computed with a window function
A rolling average averages a moving window of rows, here the current day and the six before it.
Remember: Average over a moving window of recent rows: a rolling average.
How it works
Aggregation combines rows into summaries, such as sums or averages; grouping does that per category.
A rolling average averages a window of rows that moves with each row, such as the last seven days.
Pivoting reshapes rows into columns, for example one column per region.
Clues in the question
The words that point to the answer, and what each one tells you.
- That day and the six days before it
- A moving seven-day window.
In detail
- In SQL, AVG() OVER (ORDER BY day ROWS BETWEEN 6 PRECEDING AND CURRENT ROW) computes it.
- Aggregation, grouping and pivoting are related operations with different purposes.
Side by side with look-alikes
| Operation | Does |
|---|---|
| Rolling average | Average over a moving window |
| Grouping | Summaries per category |
| Pivoting | Rows into columns |
| Aggregation | Rows into a summary |
Every option, checked
Knowing why each wrong option fails is how you rule it out on exam day.
A. A pivot of sales by regionWrongMost tempting
A pivot turns rows into columns.
Why it tempts: Pivots are a common dashboard transformation. But they reshape data; they do not average a moving window.
B. A simple total for the whole yearWrong
A yearly total is one number, not a daily moving value.
C. A random sample of daysWrong
Sampling picks a subset; it does not average a window.
D. A seven-day rolling average, computed with a window functionRight
Average over a moving window of recent rows: a rolling average.
In practice
- Use a window function rather than self-joins for rolling calculations.
Use case
An illustrative scenario, not a real incident.
A sales dashboard smooths out weekend dips with a seven-day rolling average line.
See how it works
xychart-beta x-axis ["D1", "D2", "D3", "D4", "D5", "D6", "D7", "D8", "D9"] y-axis "Sales" 0 --> 140 bar [100, 120, 90, 130, 60, 40, 110, 125, 95] line [100, 110, 103, 110, 100, 90, 93, 96, 94]
How to read this chart
- The bars are daily sales, which jump around, especially on weekends.
- The line is the seven-day rolling average, which smooths the jumps.
- Each point on the line averages that day and up to six days before it.