Expert Answer
Anonymous
SELECT
date,
metric_value,
ROUND(AVG(metric_value) OVER (
ORDER BY date
ROWS BETWEEN 6 PRECEDING AND CURRENT ROW
), 2) AS rolling_avg_7d
FROM
tbl
ORDER BY
date;
Palantir Technologies
Apple
EPAM Systems
Addepar
NetSuite
Riot Games
Anonymous
Prepare for success with realistic, role-specific interview simulations.
Try AI Interview NowInterview question asked to Data Scientists interviewing at Palantir Technologies, Apple, Benchling and others: Write a query to calculate the rolling average of a certain metric over a period of time?.