What happens if you use a window function without a PARTITION BY clause?

Quick Overview

Explain what a SQL window function computes when its OVER clause has no PARTITION BY. Tests understanding of the single global partition, how ORDER BY and the default frame change the result for tied rows, and the cost of windowing over one large partition.

What happens if you use a window function without a PARTITION BY clause?

Role: Data Scientist

Category: Data Manipulation (SQL/Python)

Difficulty: easy

Interview Round: Other

What happens if you use a window function without a `PARTITION BY` clause? ```hint Think about the frame Ask which rows the function sees for each output row, first with an empty `OVER ()` and then with only an `ORDER BY` inside it. ``` ### What a Strong Answer Covers - The whole result set (after `WHERE`, `GROUP BY` and `HAVING`) becomes a single partition - The difference between an empty `OVER ()` and `OVER (ORDER BY ...)`, including the default frame and how ties are treated - Typical uses, such as share of total and global rankings - The performance cost of one large partition ### Follow-up Questions - How does adding `ROWS BETWEEN UNBOUNDED PRECEDING AND CURRENT ROW` change a running total when the `ORDER BY` column has ties? - How would you compute each department's share of company-wide salary in one query? - Why does Spark warn when a window has no partition, and what would you do about it?

Overview: Explain what a SQL window function computes when its OVER clause has no PARTITION BY. Tests understanding of the single global partition, how ORDER BY and the default frame change the result for tied rows, and the cost of windowing over one large partition.

General logo
General
Nov 24, 2026
easyData ScientistOtherData Manipulation (SQL/Python)
0
0

What happens if you use a window function without a PARTITION BY clause?

What a Strong Answer Covers Guidance

  • The whole result set (after WHERE , GROUP BY and HAVING ) becomes a single partition
  • The difference between an empty OVER () and OVER (ORDER BY ...) , including the default frame and how ties are treated
  • Typical uses, such as share of total and global rankings
  • The performance cost of one large partition

Follow-up Questions Guidance

  • How does adding ROWS BETWEEN UNBOUNDED PRECEDING AND CURRENT ROW change a running total when the ORDER BY column has ties?
  • How would you compute each department's share of company-wide salary in one query?
  • Why does Spark warn when a window has no partition, and what would you do about it?