Timedora
Free Practice Quiz Question List

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.

10 questions
01
Choose one
1 point

In a window function, what roles do PARTITION BY and ORDER BY play?

  1. A

    PARTITION BY sets row order, and ORDER BY removes rows from the result.

  2. B

    PARTITION BY separates calculations by group, and ORDER BY defines sequence or ranking within a group.

  3. C

    PARTITION BY combines all groups, and ORDER BY determines the output columns.

  4. D

    PARTITION BY aggregates rows into one result, and ORDER BY repeats that result.

02
Choose one
1 point

When organizing an analytical query into purpose-named CTE stages, what should you verify before combining results?

  1. A

    Use the same grain in every stage so that joins never change the number of rows.

  2. B

    Check the grain only after the final query has run.

  3. C

    Give each stage a clear purpose and verify what one row represents before combining results.

  4. D

    Avoid aggregation in CTEs because it makes the grain unclear.

03
Choose one
1 point

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?

  1. A

    Create a complete daily date spine, fill missing daily values with zero, then apply the seven-row frame.

  2. B

    Apply the frame directly to transaction rows because seven rows always represent seven calendar days.

  3. C

    Remove dates without transactions before applying the frame.

  4. D

    Use PARTITION BY on the date column to make each row represent a calendar day.

04
Choose one
1 point

For a monthly cohort-retention table, how is a cohort defined and what denominator is used for retention?

  1. A

    Assign users by their most recent event month and divide by active users in the period.

  2. B

    Assign users by their first recorded event day and divide by the number of events.

  3. C

    Assign users by the month of their first event, then divide active users by that month’s retained users.

  4. D

    Assign users by the month of their first recorded event, then divide cohort users active in a period by the cohort size.

05
Choose one
1 point

A monthly report must return exactly three product rows per month, even when revenues tie. Which ranking approach fits that requirement?

  1. A

    Use RANK() <= 3; it always returns exactly three rows, including when values tie.

  2. B

    Use ROW_NUMBER() with a deterministic tie-breaker when exactly three rows are required.

  3. C

    Use DENSE_RANK() <= 3; it always returns exactly three rows, including when values tie.

  4. D

    Use RANK() <= 3 and remove the tie-breaker so tied rows are counted once.

06
Choose one
1 point

In a calendar-day rolling-revenue calculation, how should dates with no transactions be represented before applying the row-based frame?

  1. A

    Remove dates without transactions and let the window frame skip them.

  2. B

    Use COUNT(*) over the transaction table to generate zero-revenue days.

  3. C

    Create a daily date spine, left join daily revenue, and replace missing revenue with zero.

  4. D

    Apply the window frame before aggregating transactions by date.

07
Choose one
1 point

Which window function numbers rows uniquely within each partition?

  1. A

    ROW_NUMBER()

  2. B

    RANK()

  3. C

    DENSE_RANK()

  4. D

    SUM()

08
Choose one
1 point

How can a cohort-retention table include a row for a cohort-period in which no users returned?

  1. A

    Use an inner join so only cohort-periods with activity appear.

  2. B

    Remove cohort-periods with no matching activity before aggregation.

  3. C

    Add a matching activity row for every user in every period.

  4. D

    Build a cohort-period grid and left join activity so periods with no matches remain.

09
Choose one
1 point

What can happen when a monthly product-ranking query filters with RANK() <= 3?

  1. A

    It selects at most three products because RANK() breaks ties automatically.

  2. B

    It selects the top three rank positions, so ties can produce more than three products.

  3. C

    It selects all products ranked below position three.

  4. D

    It selects exactly three products unless there are no products in a month.

10
Choose one
1 point

Which statement accurately describes the role of CTEs in an analytical query?

  1. A

    A CTE is always stored as a permanent intermediate table.

  2. B

    A CTE always forces the database to run each stage separately.

  3. C

    A CTE organizes a query, but is not necessarily stored or a performance optimization.

  4. D

    A CTE can only be referenced by the query that immediately follows it.