Skip to content
LakeBench
ProblemsCommunityPricing
Sign inStart practicing
Back
  1. Home
  2. Interview prep
  3. What is a window function?

SQL · Window Functions

What is a window function?

Mediumsql-16
window functionsoveranalytics

Question

What is a window function?

Solution

A window function performs calculations across related rows without collapsing them.

Example:

SELECT
    employee,
    department,
    salary,
    AVG(salary) OVER (PARTITION BY department) AS dept_avg
FROM employees;

Every employee remains a row.

Compare:

GROUP BY department

which collapses multiple employees into one department row.

Difference:

> GROUP BY reduces rows. > Window functions keep rows.

🎯 Put this concept into practice

Solidify this answer with real hands-on interview drills in the browser studio.

Open related drill →
PreviousNext