What is a key effect of using a window function with an OVER clause?
SQL Window Functions and Cohort Retention Online Quiz Questions
Use this free practice quiz with 10 questions to review SQL Window Functions and Cohort Retention, test your knowledge, and prepare for your next test or exam.
When rows tie on the ranking expression, how does RANK() differ from DENSE_RANK()?
- A
RANK() leaves gaps after ties; DENSE_RANK() does not.
- B
RANK() assigns unique numbers to ties; DENSE_RANK() leaves gaps.
- C
RANK() and DENSE_RANK() both assign each tied row a unique number.
- D
DENSE_RANK() leaves gaps after ties; RANK() does not.
In an ordered partition, what does amount - LAG(amount) calculate for each row?
- A
Add the current amount to the amount in the next row.
- B
Return the average of all rows in the partition.
- C
Subtract the previous row's amount from the current row's amount.
- D
Subtract the current row's amount from the first row's amount.
How is cohort retention percentage calculated for a particular cohort and activity month?
- A
Divide the cohort size by the number of active users, then multiply by 100.
- B
Divide active users by the original cohort size, then multiply by 100.
- C
Divide active users by the number of activity months, then multiply by 100.
- D
Subtract active users from the original cohort size, then multiply by 100.
You need a deterministic unique position for each employee within a department, including when salaries tie. Which approach best meets that need?
- A
Use RANK() and remove all employees with equal salaries.
- B
Use DENSE_RANK() because it assigns unique numbers to ties.
- C
Use ROW_NUMBER() ordered only by department.
- D
Use ROW_NUMBER() ordered by salary and a stable tie-breaker such as employee_id.
When calculating active users for a cohort and activity month, how should multiple events by the same user in that month be treated?
- A
Count every event, even if one user has multiple events in the month.
- B
Count each user once for the entire cohort, regardless of activity month.
- C
Count each user once per activity month, even if they had multiple events that month.
- D
Count only users who were active in every month after their cohort month.
A rolling average uses ROWS BETWEEN 2 PRECEDING AND CURRENT ROW ordered by month. If some months have no rows, what does this frame describe?
- A
It averages up to three rows, which may not be three consecutive calendar months.
- B
It averages exactly three consecutive calendar months, even if data is missing.
- C
It averages only the two preceding rows and excludes the current row.
- D
It averages all rows from the start of the account's history.
Within an OVER clause, what roles do PARTITION BY and ORDER BY play?
- A
PARTITION BY sets the sequence; ORDER BY divides rows into groups.
- B
PARTITION BY divides rows into groups; ORDER BY determines their sequence.
- C
PARTITION BY removes duplicate rows; ORDER BY filters the calculation.
- D
PARTITION BY sorts the final output; ORDER BY defines the frame size.
A cohort-retention query based on recorded activity should also display months with zero activity. What additional approach is needed?
- A
Use RANK() to add rows for missing months.
- B
Replace the cohort size with zero for months without activity.
- C
Use an inner join to create the missing month rows.
- D
Generate a calendar of cohort-month pairs and left join the activity counts.
In PostgreSQL, what does the default frame for an ordered aggregate window generally produce?
- A
It always includes every row in the partition, regardless of ordering.
- B
It selects only the next row in the partition.
- C
It generally produces a running result through the current row and its peers.
- D
It produces a fixed three-row rolling average.
Related study packs and tools
1 Network Security Foundations and Threats
Learn how network security goals, threat modeling, identity and access controls, and layered defenses help protect connected systems and support recovery.
1 Network Troubleshooting Method
Learn a disciplined workflow for defining network problems, gathering evidence, testing likely causes, applying controlled fixes, and confirming and documenting the results.
1 Networking Fundamentals
A medium-difficulty quiz on networking fundamentals, including communication roles, protocol layers, data units, and network models.
2 Protocols and Ports
A medium-difficulty quiz on interpreting network protocols, ports, and common traffic patterns.
2 Virtual Machines
A medium-difficulty quiz on virtual machine architecture, provisioning, networking, storage, and operations.
4 Mobile Connectivity
A 14-question quiz on applying mobile connectivity concepts to common settings, usage, and troubleshooting situations.
5 Cloud Service Models
A medium-difficulty quiz on applying and distinguishing IaaS, PaaS, and SaaS, including their responsibilities, trade-offs, and appropriate uses.
5 Diagnosing Mobile Device Problems
Learn to diagnose mobile-device power, battery, touchscreen, connectivity, app, and operating-system problems using safe checks and a systematic process.
5 Network Operations and Reliability
A medium-difficulty quiz on network operations, monitoring, configuration management, resilience, and recovery planning.
6 Security Operations and Incident Response
Learn how security teams monitor activity, manage vulnerabilities, respond to incidents, preserve digital evidence, and restore services safely.
7 Integrated Troubleshooting Practice
A practical workflow for isolating mixed hardware, display, storage, mobile-device, and network problems, protecting data, and verifying repairs.
8 Comprehensive Security+ Practice and Review
A scenario-focused guide to Security+ SY0-701 concepts, emphasizing evidence-based incident response, access control, cryptography, vulnerability handling, recovery objectives, and risk governance.