In a window function, what roles do PARTITION BY and ORDER BY play?
SQL Analytics: Windows, Cohorts, and Ranking Online Quiz Questions
Use this free practice quiz with 10 questions to review SQL Analytics: Windows, Cohorts, and Ranking, test your knowledge, and prepare for your next test or exam.
When organizing an analytical query into purpose-named CTE stages, what should you verify before combining results?
- A
Use the same grain in every stage so that joins never change the number of rows.
- B
Check the grain only after the final query has run.
- C
Give each stage a clear purpose and verify what one row represents before combining results.
- D
Avoid aggregation in CTEs because it makes the grain unclear.
A report needs a seven-calendar-day rolling total, but some dates have no transactions. Which approach makes a row-based window frame represent calendar days?
- A
Create a complete daily date spine, fill missing daily values with zero, then apply the seven-row frame.
- B
Apply the frame directly to transaction rows because seven rows always represent seven calendar days.
- C
Remove dates without transactions before applying the frame.
- D
Use
PARTITION BYon the date column to make each row represent a calendar day.
For a monthly cohort-retention table, how is a cohort defined and what denominator is used for retention?
- A
Assign users by their most recent event month and divide by active users in the period.
- B
Assign users by their first recorded event day and divide by the number of events.
- C
Assign users by the month of their first event, then divide active users by that month’s retained users.
- D
Assign users by the month of their first recorded event, then divide cohort users active in a period by the cohort size.
A monthly report must return exactly three product rows per month, even when revenues tie. Which ranking approach fits that requirement?
- A
Use
RANK() <= 3; it always returns exactly three rows, including when values tie. - B
Use
ROW_NUMBER()with a deterministic tie-breaker when exactly three rows are required. - C
Use
DENSE_RANK() <= 3; it always returns exactly three rows, including when values tie. - D
Use
RANK() <= 3and remove the tie-breaker so tied rows are counted once.
In a calendar-day rolling-revenue calculation, how should dates with no transactions be represented before applying the row-based frame?
- A
Remove dates without transactions and let the window frame skip them.
- B
Use
COUNT(*)over the transaction table to generate zero-revenue days. - C
Create a daily date spine, left join daily revenue, and replace missing revenue with zero.
- D
Apply the window frame before aggregating transactions by date.
Which window function numbers rows uniquely within each partition?
- A
ROW_NUMBER() - B
RANK() - C
DENSE_RANK() - D
SUM()
How can a cohort-retention table include a row for a cohort-period in which no users returned?
- A
Use an inner join so only cohort-periods with activity appear.
- B
Remove cohort-periods with no matching activity before aggregation.
- C
Add a matching activity row for every user in every period.
- D
Build a cohort-period grid and left join activity so periods with no matches remain.
What can happen when a monthly product-ranking query filters with RANK() <= 3?
- A
It selects at most three products because
RANK()breaks ties automatically. - B
It selects the top three rank positions, so ties can produce more than three products.
- C
It selects all products ranked below position three.
- D
It selects exactly three products unless there are no products in a month.
Which statement accurately describes the role of CTEs in an analytical query?
- A
A CTE is always stored as a permanent intermediate table.
- B
A CTE always forces the database to run each stage separately.
- C
A CTE organizes a query, but is not necessarily stored or a performance optimization.
- D
A CTE can only be referenced by the query that immediately follows it.
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.