Timedora
Free Practice Quiz Question List

PostgreSQL Window Frames and Rolling Metrics Online Quiz Questions

Use this free practice quiz with 10 questions to review PostgreSQL Window Frames and Rolling Metrics, test your knowledge, and prepare for your next test or exam.

10 questions
01
Choose one
1 point

A query uses ROWS BETWEEN 6 PRECEDING AND CURRENT ROW. Which statement best describes the frame?

  1. A

    It always includes every row whose date falls within the previous seven calendar days.

  2. B

    It includes at most seven physical rows, which represent seven consecutive calendar days only if there is one row per calendar day.

  3. C

    It includes seven peer groups that share the same ordering value.

  4. D

    It includes all rows with the same ordering value as the current row.

02
Choose one
1 point

Before calculating daily metrics, how should a system handle timestamps when the reporting day follows a specified local time zone?

  1. A

    Keep all timestamps in UTC and use their UTC dates, regardless of the reporting calendar.

  2. B

    Calculate daily metrics first, then assign each result to a reporting time zone.

  3. C

    Choose the reporting time zone and bucket timestamps into its business dates before calculating daily metrics.

  4. D

    Convert timestamps to dates only after filtering out dates with no activity.

03
Choose one
1 point

Which approach supports a safe percentage-change calculation comparing each day's revenue with the previous day's revenue?

  1. A

    Use LEAD to retrieve the next day's value, then divide by the current day's revenue.

  2. B

    Use SUM over the same frame, then divide by the number of rows.

  3. C

    Use LAG and divide by the previous value without checking whether it is zero.

  4. D

    Use LAG to retrieve the previous value, expose it in a later query layer, and use NULLIF(previous_day_revenue, 0) as the denominator.

04
Choose one
1 point

A report needs complete seven-day rolling totals, including zero-activity days. Which preparation best supports the first reported date having a full window?

  1. A

    Aggregate only dates with orders, then begin the calculation at the report start date.

  2. B

    Create a calendar, left join the records, assign zero to missing activity when appropriate, and include enough pre-report dates to fill the first window.

  3. C

    Create dates only after calculating the rolling metric, then add them to the final output.

  4. D

    Replace missing dates with the previous day's revenue and begin the window at the report start date.

05
Choose one
1 point

Which description of an offset RANGE frame for date or timestamp ordering in PostgreSQL is accurate?

  1. A

    RANGE counts peer groups, and its offset is a number of physical rows.

  2. B

    RANGE counts physical rows, and its offset is an interval of peer groups.

  3. C

    RANGE measures distance in the ordering value; a PostgreSQL offset frame for date/time ordering uses an interval and a single ORDER BY expression.

  4. D

    RANGE always includes exactly one row for every calendar date in the interval.

06
Choose one
1 point

A business's reporting day follows a local time zone rather than UTC. What should happen before daily metrics are calculated?

  1. A

    Bucket timestamps into business dates in the chosen reporting time zone before computing daily metrics.

  2. B

    Always use UTC dates, even when business days follow a different time zone.

  3. C

    Assign timestamps to business dates using the time zone of the database server.

  4. D

    Calculate daily metrics using timestamp values without choosing a reporting time zone.

07
Choose one
1 point

A complete calendar assigns zero revenue to dates with no orders. What does this mean for a rolling average over those dates?

  1. A

    Missing dates must be removed because a rolling average cannot include them.

  2. B

    Missing dates should always be assigned the previous active day's revenue.

  3. C

    Missing dates should be excluded from every rolling average, without any additional rule.

  4. D

    If missing dates are filled with zero, they are included in the average; averaging only active days requires a separate rule.

08
Choose one
1 point

What does a SQL window frame using GROUPS count?

  1. A

    GROUPS measures a distance in the ordering value.

  2. B

    GROUPS counts peer groups rather than individual rows.

  3. C

    GROUPS always counts exactly seven calendar dates.

  4. D

    GROUPS counts only rows with unique ordering values.

09
Choose one
1 point

A percentage-change expression needs the result of LAG. How can the query make that result available for the calculation?

  1. A

    Put both window functions into a single expression so the second can use the first result.

  2. B

    Use GROUPS instead of LAG to return the previous row's value.

  3. C

    Calculate LAG in one query layer and use its result in a later CTE or query layer.

  4. D

    Calculate the percentage change before retrieving the previous row's value.

10
Choose one
1 point

A ROWS frame orders records by date, but several records share each date. What can make a row-by-row calculation's ordering meaningful?

  1. A

    Aggregate to one row per date or add a unique tie-breaker if the calculation is intended to be row-by-row.

  2. B

    Remove the ORDER BY clause so PostgreSQL can choose a consistent row sequence.

  3. C

    Use RANGE in every case where multiple rows share a date.

  4. D

    Sort by the date alone because rows with the same date have a guaranteed unique order.