In a window function, what do PARTITION BY and ORDER BY control?
PARTITION BY starts a separate window calculation for each group; ORDER BY defines sequence or ranking within each group.
Study SQL Window Functions, Cohorts, and Ranking with 12 free online flashcards. Review key terms, definitions, and concepts with this interactive flashcard deck.
In a window function, what do PARTITION BY and ORDER BY control?
PARTITION BY starts a separate window calculation for each group; ORDER BY defines sequence or ranking within each group.
Why may ROWS BETWEEN 6 PRECEDING AND CURRENT ROW not represent seven calendar days?
The frame contains seven rows, not necessarily seven calendar days. Add a complete daily date series and fill missing values with zero when missing dates must count.
How is a monthly user cohort defined, and what is month 0?
A cohort groups users by the month of their first recorded event. Month 0 is that cohort month.
How is a CTE introduced, and where can it be referenced?
A CTE is introduced by WITH, has a name and a parenthesized query, and is available to later CTEs or the final query in that statement.
How do you choose between the top three RANK() positions and exactly three rows?
RANK() <= 3 selects the top three rank positions, so ties can return more than three rows. Use ROW_NUMBER() with a deterministic tie-breaker for exactly three rows per group.
How does a window function differ from ordinary aggregation in its output?
Unlike ordinary aggregation, a window function returns a value for each input row.
Why include a six-day lookback before the first reported day in a seven-day rolling metric?
Include six days before the first reported date so its seven-day window contains the current day and six preceding days.
What does a query stage's grain mean, and why check it?
The grain is what one row represents. Checking each stage's grain before joining or applying a window function helps prevent duplicate counting.
How is monthly cohort retention calculated?
Divide the number of cohort users with at least one event in that month by the cohort size. Deduplicating activity to one row per user and month avoids counting a user more than once.
What should happen before ranking aggregated results within groups?
Aggregate to the intended grain first, then rank within the required group, ordering by the measure. For monthly product sales, aggregate to one row per month and product before ranking.
How can a row-based frame calculate a calendar-day rolling total when dates are missing?
Create a complete daily date spine, join the daily values to it, replace missing values with zero, and then apply the row-based window frame.
How do RANK() and DENSE_RANK() differ when values tie?
RANK() assigns tied values the same rank and leaves gaps after ties. DENSE_RANK() also ties equal values but leaves no gaps.
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.