QuizzesWindow Function Basics — Concept Check
intermediate
sql

Window Function Basics — Concept Check

Questions on Window Function Basics. Window functions compute a value for each row using a sliding "window" of related rows, without collapsing the result set the way GROUP BY does.

8 minutes 8 questions Pass at 70%
Time Limit
8 minutes - timer starts when you begin
Change Answers Freely
Revisit and change any answer before submitting
Full Review After Submit
Correct answers and explanations shown for every question
Auto-submit on timeout
Quiz submits automatically when time runs out

Questions in this quiz

8 questions on Window Function Basics — Concept Check. Work through them here, then start the quiz to answer them and see your score.

  1. 1.You have a query using a window function with PARTITION BY user_id. What happens if you remove PARTITION BY?

    • AThe query will return an error.
    • BThe window function will not execute.
    • CEach row will be treated as a separate window.
    • DThe entire result set is treated as one window.
  2. 2.A report shows the top 3 sales amounts per user. Which SQL construct ensures each row is visible while computing this?

    • AHAVING clause
    • BPARTITION BY inside OVER()
    • CGROUP BY
    • DJOIN operation
  3. 3.A developer uses ORDER BY inside OVER() but notices unexpected results with ties. What might be the issue?

    • AThe frame clause is incorrectly specified.
    • BPARTITION BY is missing, causing errors.
    • CRANGE is used, causing tie-related surprises.
    • DROWS is used, causing incorrect row counts.
  4. 4.Why can't you filter directly on a window function result in a WHERE clause?

    • AWindow functions require GROUP BY.
    • BFiltering requires a JOIN operation.
    • CWindow functions don't support filtering.
    • DWindow functions execute after WHERE.
  5. 5.A query uses ROWS BETWEEN 2 PRECEDING AND CURRENT ROW. What does this frame specify?

    • AOnly the current row as the window.
    • BA cumulative sum of all preceding rows.
    • CThe entire partition as the window.
    • DA moving window of the last 3 rows including the current row.
  6. 6.What happens if you use GROUP BY instead of PARTITION BY in a window function query?

    • AThe query will return the same result.
    • BThe window function will compute incorrectly.
    • CAn error will be thrown.
    • DRows are collapsed into summary rows per group.
  7. 7.A query uses SUM(amount) OVER (ORDER BY created_at). What is the result?

    • AA total sum of all amounts in the table.
    • BA running total of amounts ordered by created_at.
    • CAn error due to missing PARTITION BY.
    • DA sum of amounts for each unique created_at.
  8. 8.When using a window function, why might a CTE or subquery be necessary?

    • ATo enable the use of GROUP BY.
    • BTo improve query performance.
    • CTo filter results based on the window function output.
    • DTo avoid syntax errors in the main query.