When should timestamps be bucketed into business dates?
Bucket timestamps into business dates in the chosen reporting time zone before calculating daily metrics. PostgreSQL’s date_trunc can truncate timestamps to a chosen unit.
Study SQL Time-Series Window Functions with 12 free online flashcards. Review key terms, definitions, and concepts with this interactive flashcard deck.
When should timestamps be bucketed into business dates?
Bucket timestamps into business dates in the chosen reporting time zone before calculating daily metrics. PostgreSQL’s date_trunc can truncate timestamps to a chosen unit.
How can SQL retrieve a previous period’s value for comparison?
Use LAG with an ordering column to retrieve the previous row’s value. Expose that result in a later CTE or query layer before using it in another calculation.
When does a seven-row ROWS frame represent seven calendar days?
ROWS BETWEEN 6 PRECEDING AND CURRENT ROW includes at most seven physical rows. It represents seven consecutive calendar days only when there is exactly one row per calendar day.
How do window aggregates calculate rolling metrics without collapsing dates?
Apply a window aggregate over an explicitly defined, ordered frame. This calculates rolling measures while retaining one output row per date.
How do you prepare daily data when zero-activity dates should count?
Aggregate records to the reporting grain first. If zero-activity dates should count, create a complete calendar, left join the data, and convert missing activity to zero.
What does RANGE measure in a SQL window frame?
RANGE measures distance in the ordering value rather than counting rows. In PostgreSQL, an offset RANGE frame for date or timestamp ordering uses an interval and requires a single ORDER BY expression.
Which aggregates can use a seven-row rolling frame?
SUM, AVG, and COUNT can use ROWS BETWEEN 6 PRECEDING AND CURRENT ROW to calculate measures over the current row and up to six preceding rows.
How can percentage change use LAG safely?
Put the LAG result in a later CTE or query layer, then use NULLIF(previous_day_revenue, 0) as the percentage-change denominator to avoid division by zero.
When should you filter report dates for a rolling metric?
Include enough dates before the report start to complete the first rolling window. Calculate the metric over that expanded range, then filter to the displayed report dates.
Why might UTC dates be unsuitable for daily business metrics?
Use the chosen reporting time zone to assign timestamps to business-date buckets before calculating daily metrics. UTC dates may not match local business dates.
What does LAG(revenue) OVER (ORDER BY day) return?
LAG(revenue) OVER (ORDER BY day) retrieves the revenue from the previous row in day order, which can be used to compare consecutive days.
What does filling missing dates with zero do to a rolling average?
A calendar and left join can fill dates without orders; converting their revenue to zero makes those dates part of the rolling average. For active days only, define a separate counting rule.
Learn how network security goals, threat modeling, identity and access controls, and layered defenses help protect connected systems and support recovery.
Learn a disciplined workflow for defining network problems, gathering evidence, testing likely causes, applying controlled fixes, and confirming and documenting the results.
A medium-difficulty quiz on networking fundamentals, including communication roles, protocol layers, data units, and network models.
A medium-difficulty quiz on interpreting network protocols, ports, and common traffic patterns.
A medium-difficulty quiz on virtual machine architecture, provisioning, networking, storage, and operations.
A 14-question quiz on applying mobile connectivity concepts to common settings, usage, and troubleshooting situations.
A medium-difficulty quiz on applying and distinguishing IaaS, PaaS, and SaaS, including their responsibilities, trade-offs, and appropriate uses.
Learn to diagnose mobile-device power, battery, touchscreen, connectivity, app, and operating-system problems using safe checks and a systematic process.
A medium-difficulty quiz on network operations, monitoring, configuration management, resilience, and recovery planning.
Learn how security teams monitor activity, manage vulnerabilities, respond to incidents, preserve digital evidence, and restore services safely.
A practical workflow for isolating mixed hardware, display, storage, mobile-device, and network problems, protecting data, and verifying repairs.
A scenario-focused guide to Security+ SY0-701 concepts, emphasizing evidence-based incident response, access control, cryptography, vulnerability handling, recovery objectives, and risk governance.